Select to List data from another table

1

I have a system from which I register the personal data enc_dados_pessoais and another table that stores complementary data enc_dados_complementares .

In the personal data table, the user registers only the basic information and clicking next , goes to the complementary data. I need to list only the users who did not finalize the supplementary data.

The primary key of the enc_dados_pessoais table is IdUsuarios and the foreign key of the enc_dados_complementares table is IdUsuarios . So I did it this way:

SELECT * FROM enc_dados_principais princ LEFT JOIN enc_dados_complementares
comp ON princ.IdUsuarios <> comp.IdUsuarios;

But it is not returning those who did not fill, only those who filled in the supplementary data.

I have already tried to use INNER JOIN , RIGHT JOIN and JOIN , but it also did not work.

    
asked by anonymous 15.06.2015 / 16:49

1 answer

3

Based on the comment from colleague Marconi , I solved the problem using NOT IN :

select * from enc_dados_principais where IdUsuarios not in 
(SELECT IdUsuarios FROM enc_dados_complementares);
    
15.06.2015 / 17:37