2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost`
|
2024-01-15 11:31:03 +00:00
|
|
|
SQL SECURITY DEFINER
|
|
|
|
VIEW `vn`.`clientPhoneBook`
|
|
|
|
AS SELECT `c`.`id` AS `clientFk`,
|
|
|
|
trim(`c`.`phone`) AS `phone`
|
|
|
|
FROM `vn`.`client` `c`
|
|
|
|
WHERE `c`.`phone` <> 0
|
|
|
|
AND `c`.`isActive` <> 0
|
|
|
|
UNION
|
|
|
|
SELECT `c`.`id` AS `clientFk`,
|
|
|
|
trim(`c`.`mobile`) AS `phone`
|
|
|
|
FROM `vn`.`client` `c`
|
|
|
|
WHERE `c`.`mobile` <> 0
|
|
|
|
AND `c`.`isActive` <> 0
|
|
|
|
UNION
|
|
|
|
SELECT `a`.`clientFk` AS `clientFk`,
|
|
|
|
trim(`a`.`phone`) AS `phone`
|
|
|
|
FROM (
|
|
|
|
`vn`.`address` `a`
|
|
|
|
JOIN `vn`.`client` `c` ON(`c`.`id` = `a`.`clientFk`)
|
|
|
|
)
|
|
|
|
WHERE `a`.`phone` <> 0
|
|
|
|
AND `c`.`isActive` <> 0
|
|
|
|
UNION
|
|
|
|
SELECT `a`.`clientFk` AS `clientFk`,
|
|
|
|
trim(`a`.`mobile`) AS `phone`
|
|
|
|
FROM (
|
|
|
|
`vn`.`address` `a`
|
|
|
|
JOIN `vn`.`client` `c` ON(`c`.`id` = `a`.`clientFk`)
|
|
|
|
)
|
|
|
|
WHERE `a`.`mobile` <> 0
|
|
|
|
AND `c`.`isActive` <> 0
|
|
|
|
UNION
|
|
|
|
SELECT `cc`.`clientFk` AS `clientFk`,
|
|
|
|
trim(`cc`.`phone`) AS `phone`
|
|
|
|
FROM (
|
|
|
|
`vn`.`clientContact` `cc`
|
|
|
|
LEFT JOIN `vn`.`client` `c` ON(`c`.`id` = `cc`.`clientFk`)
|
|
|
|
)
|
|
|
|
WHERE `c`.`phone` <> 0
|
|
|
|
AND `c`.`isActive` <> 0
|