Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
http://sqlfiddle.com/#!2/41cf8/1
我实际上希望它返回这样的东西
firstname - chuck lastname - null
但它只返回我的名字行
我如何修改它以返回带有空值的姓氏?
谢谢你
您需要将AND users_meta.meta_user_id = 1WHERE 子句移到 JOIN 子句中。
AND users_meta.meta_user_id = 1
在 WHERE 子句中,它限制了返回的行。在 JOIN 中,它仅限制 JOINed 行,并且由于您使用的是 LEFT 连接,您仍然会得到姓氏。