I need to select data from a table only when the codigo
of this table is not in a second table. Briefly that would be it. I have the entregaitem
table with the following (codigo,codigoentrega,codigoestoque)
columns and the retorno
table where one of the columns is (codigoentregaitem)
. My requirement is to create a query
that will select all items in the entregaitem
table when codigo
does not exist in the retorno
table, I thought of something like:
select * from public.entregaitem where NOT EXITS
(select public.entregaitem.codigo, public.retorno.codigoentregaitem
from public.entregaitem,public.retorno
where public.entregaitem.codigo = public.retorno.codigoentregaitem)
But nothing has been returned to me. Because there is data where the code is different