Error executing INTERSECT in MySql

0

I want to select the employees of the employee table who are managers, so I'm trying to use INTERSECT but it's not working, I think the image says it all too, would you have another way to do it?

    
asked by anonymous 11.06.2018 / 20:25

1 answer

1

For the example you presented the code below will serve:

Select Gerentes.*, Funcionario.* from Funcionario JOIN Gerentes ON (Funcionario.Nome = Gerentes.Nome)

Just one caveat. In the image that showed there is no key between the two tables (Managers and Employees). I made the JOIN with the NAME field, because it was the only field I saw that could capture, but this is not ideal.

If possible create a foreign key in the table so that this JOIN is most effective and useful (in case there are two employees or managers with the same name this instruction will not work)

Creating a foreign key in MySQL

Adding a foreign key in a table already created

Adding a foreign key in mySQL

What is the use of using foreign keys?

    
11.06.2018 / 20:54