1
Good afternoon guys, I am learning SQL and I have to do an exercise that is: Select the first and last names of employees and consultants working in the "Financial" department.
Turns out I’m trying to use this query
SELECT nmemp, snemp, nmconsult FROM emp, consult
WHERE consult.coddepto = emp.coddepto AND
emp.coddepto in(Select coddepto from depto where nmdepto = 'financeiro')
I tried to use John too but it didn’t help
SELECT nmemp, snemp,nmconsult FROM emp
LEFT JOIN consult ON consult.coddepto = emp.coddepto
LEFT JOIN depto ON nmdepto = 'financeiro' AND consult.coddepto = depto.coddepto
The result is going wrong as in the image below, I would like to know what I am missing, because I can’t find my mistake
Below follows the images with the table names that need to be used
Table name = Consult https://i.stack.Imgur.com/rNnI4.png
Table name = depto https://i.stack.Imgur.com/8tna7.png
Table name = emp https://i.stack.Imgur.com/oCnf6.png
Thank you very much, I kept reading the query here and now I understand how UNION ALL works, at first I was having difficulties using it now with your explanation I managed to understand well, thank you
– Signatuz