24 lines
633 B
MySQL
24 lines
633 B
MySQL
|
CREATE OR REPLACE DEFINER=`root`@`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`)
|
||
|
)
|