Another way to do a not exists SQL query with best performance
This comes up again and again as a thorny and persistent problem. I got this new way of doing this from my friend.
SELECT alias1.PKCol1, alias1.Col2
FROM table1 alias1
WHERE alias1.Col3= 11 AND alias1.Col4= 43 AND
NOT EXISTS (SELECT 'x' FROM table2 alias2 WHERE alias2.PKCol1 = alias1.PKCol1)
SELECT alias1.PKCol1, alias1.Col2
FROM table1 alias1
WHERE alias1.Col3= 11 AND alias1.Col4= 43 AND
NOT EXISTS (SELECT 'x' FROM table2 alias2 WHERE alias2.PKCol1 = alias1.PKCol1)
Comments
Post a Comment