Relationship between tables of same values in columns

0

I want to do a sql query that lists two columns of two different tables, which store the same types of values, but one has some that the other does not contain, eg:

Table 1 has the column code and

Table 2 has the column code

I want to make a query that displays all code lines that are not in code

Thanks in advance for any help

    
asked by anonymous 20.11.2017 / 00:09

1 answer

2

A solution (among others) is to use a sub-select with not exists, check the existence of values in the sub-select

select * 
from tabela2
where not exists (select null
                  from tabela1
                  where tabela1.codigo = tabela2.code)
    
20.11.2017 / 00:55