What is the difference between the following pieces of SQL code:
select count(*)
from A
left join B
on a.id = b.id
where a.status = 2 and
b.id is NULL
and
select count(*)
from A
left join B
on a.id = b.id
and a.status =2
where b.id is NULL
? I read this : Semantic difference between join queries but I still don’t know which one is better to use
I have spend the past hour reading this and grasping it all answers added value but I understood the code example together with “never encountered this” the best
Rewriting the 2 queries without the
LEFT JOIN / IS NULLso it’s obvious that they can return different data sets in certain cases:and