Relation between tables of the same values in the columns

Asked

Viewed 26 times

0

I want to make an sql query that relates two columns of two different tables, which store the same types of values, but one has some that the other does not contain, example:

Table 1 owns the code column and

Table 2 owns the code column

I want to make a query that displays all lines(values) of code that are not in code

From now on, thank you for any help

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)
  • Does not work, says the code column does not belong to Tabela1 on line 5, even if it belongs

  • Indeed. It has been corrected.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.