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

23 lines
537 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`.`operatorWorkerCode`
AS SELECT `o`.`workerFk` AS `workerFk`,
concat(`w`.`firstName`, ' ', `w`.`lastName`) AS `fullName`,
`w`.`code` AS `code`,
`o`.`numberOfWagons` AS `numberOfWagons`
FROM (
(
`vn`.`worker` `w`
JOIN `vn`.`operator` `o` ON(`o`.`workerFk` = `w`.`id`)
)
JOIN `vn`.`sector` `s` ON(`o`.`sectorFk` = `s`.`id`)
)
WHERE `o`.`sectorFk` IS NOT NULL
AND `s`.`code` IN (
'H2',
'H2',
'PEQUES_H',
'ALTILLO COMP',
'ALTILLO ARTI'
)