21 lines
785 B
SQL
21 lines
785 B
SQL
USE `vn`;
|
|
CREATE
|
|
OR REPLACE ALGORITHM = UNDEFINED
|
|
DEFINER = `root`@`%`
|
|
SQL SECURITY DEFINER
|
|
VIEW `vn`.`personDepartment` AS
|
|
SELECT
|
|
`p`.`id_trabajador` AS `workerFk`,
|
|
`p`.`name` AS `name`,
|
|
`p`.`firstname` AS `firstname`,
|
|
`d`.`name` AS `department`
|
|
FROM
|
|
(((`postgresql`.`person` `p`
|
|
JOIN `postgresql`.`profile` `pr` ON ((`pr`.`person_id` = `p`.`person_id`)))
|
|
LEFT JOIN (`postgresql`.`business` `b`
|
|
LEFT JOIN `postgresql`.`business_labour` `bl` ON ((`b`.`business_id` = `bl`.`business_id`))) ON ((`pr`.`profile_id` = `b`.`client_id`)))
|
|
JOIN `vn`.`department` `d` ON ((`d`.`id` = `bl`.`department_id`)))
|
|
WHERE
|
|
(ISNULL(`b`.`date_end`)
|
|
OR (`b`.`date_end` > CURDATE()));
|