CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`traceabilityBuy` AS SELECT `b`.`id` AS `buyFk`, `b`.`quantity` AS `quantity`, `tr`.`landed` AS `landed`, `w`.`name` AS `warehouseName`, `b`.`entryFk` AS `entryFk`, `s`.`name` AS `supplierName`, IFNULL(`b`.`itemOriginalFk`, `b`.`itemFk`) AS `itemFk` FROM ( ( ( ( `vn`.`buy` `b` JOIN `vn`.`entry` `e` ON(`e`.`id` = `b`.`entryFk`) ) JOIN `vn`.`travel` `tr` ON(`tr`.`id` = `e`.`travelFk`) ) JOIN `vn`.`supplier` `s` ON(`s`.`id` = `e`.`supplierFk`) ) JOIN `vn`.`warehouse` `w` ON(`w`.`id` = `tr`.`warehouseInFk`) )