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

32 lines
824 B
MySQL
Raw Normal View History

CREATE OR REPLACE DEFINER=`vn-admin`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`floraHollandBuyedItems`
AS SELECT `b`.`itemFk` AS `itemFk`,
`i`.`longName` AS `longName`,
`b`.`quantity` AS `quantity`,
`b`.`buyingValue` AS `buyingValue`,
`tr`.`landed` AS `landed`,
`e`.`companyFk` AS `companyFk`
FROM (
(
(
(
(
`vn`.`buy` `b`
JOIN `vn`.`item` `i` ON(`b`.`itemFk` = `i`.`id`)
)
JOIN `vn`.`itemType` `it` ON(`it`.`id` = `i`.`typeFk`)
)
JOIN `vn`.`itemCategory` `ic` ON(`ic`.`id` = `it`.`categoryFk`)
)
JOIN `vn`.`entry` `e` ON(`e`.`id` = `b`.`entryFk`)
)
JOIN `vn`.`travel` `tr` ON(
`tr`.`id` = `e`.`travelFk`
AND `ic`.`id` NOT IN (8, 6)
AND `b`.`buyingValue` <> 0
AND `b`.`quantity` <> 0
AND `e`.`supplierFk` IN (1664, 1665, 1666, 1465, 1433)
)
)