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

23 lines
645 B
MySQL
Raw Normal View History

2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`phoneBook`
AS SELECT 'C' AS `Tipo`,
`vn`.`client`.`id` AS `Id`,
`vn`.`client`.`name` AS `Cliente`,
`vn`.`client`.`phone` AS `Telefono`
FROM `vn`.`client`
WHERE `vn`.`client`.`phone` IS NOT NULL
UNION
SELECT 'C' AS `Tipo`,
`vn`.`client`.`id` AS `Id`,
`vn`.`client`.`name` AS `Cliente`,
`vn`.`client`.`mobile` AS `Movil`
FROM `vn`.`client`
WHERE `vn`.`client`.`mobile` IS NOT NULL
UNION
SELECT 'C' AS `Tipo`,
`vn`.`clientContact`.`clientFk` AS `clientFk`,
`vn`.`clientContact`.`name` AS `name`,
`vn`.`clientContact`.`phone` AS `phone`
FROM `vn`.`clientContact`