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

22 lines
558 B
SQL

CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`sale_freightComponent`
AS SELECT `t`.`id` AS `ticketFk`,
`sc`.`value` * `s`.`quantity` AS `amount`,
`t`.`shipped` AS `shipped`
FROM (
(
(
(
`vn`.`ticket` `t` STRAIGHT_JOIN `vn`.`sale` `s` ON(`t`.`id` = `s`.`ticketFk`)
)
JOIN `vn`.`saleComponent` `sc` ON(`sc`.`saleFk` = `s`.`id`)
)
JOIN `vn`.`component` `c` ON(`c`.`id` = `sc`.`componentFk`)
)
JOIN `vn`.`componentType` `ct` ON(
`ct`.`id` = `c`.`typeFk`
AND `ct`.`code` = 'freight'
)
)