0
I have a table of employees and I need to extract from it a query of employees who are not registered in any of the positions (architect, landscaper and manager). The column COD of employee is the primary key of all other posts in tables.
table employee
COD | NOME
1 | joão
2 | maria
3 | josé
4 | paulo
5 | pedro
table: architect
COD | PROJETO
1 336B
table: landscaper
COD | PROJETO
3 1052
table: manager
COD | PROJETO
4 450
I tried to use the strategy of nesting the queries bringing me only people registered in the positions and then performing a select with NOT IN, so would have only employees who are not in those positions
SELECT empregado.cod
WHERE EXISTS (SELECT arquiteto.cod)
Only I would need to validate the 3 tables in a single query. Someone suggests me what is the best strategy to return employees without posts?
Hello, I just made a few adjustments here but your guidance did work. I VERY agree that the modeling is bizarre kk.
– Rafael Brito
Settings: SELECT employee.Cod FROM employee WHERE employee.Cod NOT IN (SELECT Cod FROM ARCHITECT Where employee.Cod = architect.Cod UNION SELECT Cod FROM landscaper WHERE employee.Cod = landscaper.Cod UNION SELECT Cod FROM manager WHERE employee.Cod = manager.Cod)
– Rafael Brito