CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`saleMistakeList` AS SELECT `st`.`saleFk` AS `saleFk`, `st`.`workerFk` AS `workerFk`, concat(`w2`.`firstName`, ' ', `w2`.`lastName`) AS `sacador`, `st`.`created` AS `created`, concat(`w`.`firstName`, ' ', `w`.`lastName`) AS `revisador`, `mt`.`description` AS `description`, `sm`.`created` AS `controlled` FROM ( ( ( ( ( `vn`.`saleTracking` `st` JOIN `vn`.`worker` `w2` ON(`w2`.`id` = `st`.`workerFk`) ) JOIN `vn`.`state` `s` ON( `s`.`id` = `st`.`stateFk` AND `s`.`code` IN ('PREVIOUS_PREPARATION', 'PREPARED', 'OK') ) ) LEFT JOIN `vn`.`saleMistake` `sm` ON(`st`.`saleFk` = `sm`.`saleFk`) ) LEFT JOIN `vn`.`mistakeType` `mt` ON(`mt`.`id` = `sm`.`typeFk`) ) LEFT JOIN `vn`.`worker` `w` ON(`w`.`id` = `sm`.`userFk`) )