salix/db/routines/vn/views/traceabilityBuy.sql

24 lines
631 B
MySQL
Raw Normal View History

2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`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`)
)