I have a doubt concerning the difference between a condition in Where clause and exists or not exists. I know i will not get the same results when I use first or second way, but does someone care to explain why?
For example,
SELECT ACCOUNT_NO,
CLIENT_NAME
FROM ACCOUNT a
LEFT JOIN CLIENT b
ON a.ACCOUNT_NO = b.ACCOUNT_NO
WHERE ACCOUNT_TYPE NOT IN ( 'A', 'B', 'C' )
AND
SELECT ACCOUNT_NO,
CLIENT_NAME
FROM ACCOUNT a
LEFT JOIN CLIENT b
ON a.ACCOUNT_NO = b.ACCOUNT_NO
WHERE NOT EXISTS (SELECT *
FROM ACCOUNT_DET t1
LEFT JOIN ACCOUNT t2
ON t1.ACCOUNT_NO = t2.ACCOUNT_NO
WHERE ACCOUNT_TYPE NOT IN ( 'A', 'B', 'C' ))
?
I hope you understand me, the table ACCOUNT_DET has almost identical fields as ACCOUNT, but this is a more simplified query than the one I used.