Apologies if this is is a very basic question but my SQL is a bit rusty these days.
Simple scenario, I have 2 tables, A & B and I want to return everything form table A that doesn't have a corresponding record in B. So I've tried the followwing 2 statements:
SELECT a.* FROM TableA a
LEFT JOIN TableB b ON a.id = b.id
WHERE b.id IS NULL
SELECT a.* FROM TableA a
LEFT JOIN TableB b ON (a.id = b.id AND b.id IS NULL)
They both return different results. I would have expected the results to be same for both.
What approach is correct?
Simple scenario, I have 2 tables, A & B and I want to return everything form table A that doesn't have a corresponding record in B. So I've tried the followwing 2 statements:
SELECT a.* FROM TableA a
LEFT JOIN TableB b ON a.id = b.id
WHERE b.id IS NULL
SELECT a.* FROM TableA a
LEFT JOIN TableB b ON (a.id = b.id AND b.id IS NULL)
They both return different results. I would have expected the results to be same for both.
What approach is correct?
Comment