The following two queries are returning different results, to my surprise:
SELECT *
FROM foo
JOIN bar
ON bar.id=foo.bar_id
JOIN baz
ON baz.id=foo.baz_id
LEFT JOIN zig
ON zig.foo_id=foo.id;
and:
SELECT *
FROM foo
LEFT JOIN zig
ON zig.foo_id=foo.id
JOIN bar
ON bar.id=foo.bar_id
JOIN baz
ON baz.id=foo.baz_id;
I'm imagining that it shouldn't matter when you LEFT JOIN
on zig
, since I'm not using zig
's columns when joining the bar
and baz
. However, it appears that in the latter, the JOIN
-ing of bar
and baz
swallows up the rows where zig
had null
values... why is that?