I am working on PHP page
that connects with Oracle
. I came across this SQL and I am not sure it is doing what is supposed to, so I thought I would
Am I right?
No. This query:
select tableA.id, tableA.name, tableB.details
from tableA
left join tableB
on tableB.id = tableA.id
and tableB.logId = ''
Is very different from:
select tableA.id, tableA.name, tableB.details
from tableA
left join tableB
on tableB.id = tableA.id
where tableB.logId = ''
It's the criteria for joining.
In the first case, you take from A, then join with B when there's a matching id and a logId, else leave details null.
In the second, you take from A, then join with B when there's a matching id, else leave details null, and then you keep only rows from A where there's a B match that has a logId -- eliminating rows from A in the process, and de facto turning it into an inner join.