SELECT a.foo b.bar c.foobar FROM tableOne AS a INNER JOIN tableTwo AS b ON a.pk = b.fk LEFT JOIN tableThree AS c ON b.pk = c.fk WHERE a.foo = 'something' AND c.foobar = 'somethingelse'
将where子句放在where子句后似乎将左连接变为内连接.我看到的行为是如果tableThree中没有“somethingelse”,那么将返回0行.
如果我将c.foobar =’somethingelse’移动到join子句中,则存储的连接将像左连接那样运行.
SELECT a.foo b.bar c.foobar FROM tableOne AS a INNER JOIN tableTwo AS b ON a.pk = b.fk LEFT JOIN tableThree AS c ON b.pk = c.fk AND c.foobar = 'somethingelse' WHERE a.foo = 'something'
有人可以指出一些文件,说明为什么会这样吗?非常感谢你