CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn2008`.`item_entry_out` AS SELECT `t`.`warehouse_id_out` AS `warehouse_id`, `t`.`shipment` AS `dat`, `m`.`Id_Article` AS `item_id`, - `m`.`Cantidad` AS `amount`, `t`.`delivered` <> 0 OR IFNULL(`co`.`valor`, 0) AS `delivered`, `e`.`Id_Entrada` AS `entryFk` FROM ( ( ( `vn2008`.`Compres` `m` JOIN `vn2008`.`Entradas` `e` ON(`m`.`Id_Entrada` = `e`.`Id_Entrada`) ) JOIN `vn2008`.`travel` `t` ON(`e`.`travel_id` = `t`.`id`) ) LEFT JOIN `vn2008`.`Compres_ok` `co` ON( `co`.`Id_Compra` = `m`.`Id_Compra` AND `co`.`Id_Accion` = 3 AND `co`.`valor` <> 0 ) ) WHERE `e`.`Inventario` = 0 AND `e`.`Redada` = 0 AND `m`.`Cantidad` <> 0