salix/db/routines/vn2008/views/v_barcodes.sql

22 lines
644 B
SQL

CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`v_barcodes`
AS SELECT `Articles`.`Id_Article` AS `code`,
`Articles`.`Id_Article` AS `Id_Article`
FROM `vn2008`.`Articles`
UNION ALL
SELECT `barcodes`.`code` AS `code`,
`barcodes`.`Id_Article` AS `Id_Article`
FROM `vn2008`.`barcodes`
UNION ALL
SELECT `c`.`Id_Compra` AS `Id_Compra`,
`c`.`Id_Article` AS `Id_Article`
FROM (
(
`vn2008`.`Compres` `c`
JOIN `vn2008`.`Entradas` `e` ON(`c`.`Id_Entrada` = `e`.`Id_Entrada`)
)
JOIN `vn2008`.`travel` `tr` ON(`tr`.`id` = `e`.`travel_id`)
)
WHERE `tr`.`landing` >= `util`.`VN_CURDATE`() + INTERVAL -15 DAY