SELECT `employee`.`fname`
FROM `employee`
OUTER JOIN `test` ON `employee`.`id`=`test`.`id`
WHERE `test`.`lname` <> null;
它给出语法错误。
为什么?
最佳答案
OUTER
在 LEFT OUTER JOIN
中是可选的,而不是 LEFT
SELECT `employee`.`fname`
FROM `employee`
LEFT OUTER JOIN `test` ON `employee`.`id`=`test`.`id`
WHERE `test`.`lname` is not null;
要检查 null
,请使用 is
运算符。
顺便说一句,如果您使用内部联接
,您可以删除is not null
检查。
关于mysql - 我可以将 <> 与外连接一起使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28166103/