salix/db/routines/hedera/views/myBasketDefaults.sql

27 lines
879 B
MySQL
Raw Normal View History

CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `hedera`.`myBasketDefaults`
AS SELECT coalesce(`dm`.`code`, `cm`.`code`) AS `deliveryMethod`,
coalesce(`ad`.`agencyModeFk`, `oc`.`defaultAgencyFk`) AS `agencyModeFk`,
`c`.`defaultAddressFk` AS `addressFk`,
`oc`.`defaultAgencyFk` AS `defaultAgencyFk`
FROM (
(
(
(
(
(
`hedera`.`orderConfig` `oc`
JOIN `vn`.`agencyMode` `ca` ON(`ca`.`id` = `oc`.`defaultAgencyFk`)
)
JOIN `vn`.`deliveryMethod` `cm` ON(`cm`.`id` = `ca`.`deliveryMethodFk`)
)
LEFT JOIN `vn`.`client` `c` ON(`c`.`id` = `account`.`myUser_getId`())
)
LEFT JOIN `vn`.`address` `ad` ON(`ad`.`id` = `c`.`defaultAddressFk`)
)
LEFT JOIN `vn`.`agencyMode` `a` ON(`a`.`id` = `ad`.`agencyModeFk`)
)
LEFT JOIN `vn`.`deliveryMethod` `dm` ON(`dm`.`id` = `a`.`deliveryMethodFk`)
)