I needed to retrieve information that was in one table, but not in another. Searching found that NOT EXISTS would serve this purpose, but I saw that the Left Join has the same result:
NOT EXISTS
select pedido from logintegracao as A
where not exists (select * from pagamento as B where B.idPedido = A.Pedido)
Execution Plan:
LEFTJOIN
select*fromlogintegracaoasAleftjoinpagamentoasBonA.Pedido=B.idpedidowhereB.idpedidoisnull
ExecutionPlan
Which Query would have the best performance? Are both ways correct?