MySQL OUTER JOIN 语法错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12473210/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:52:59  来源:igfitidea点击:

MySQL OUTER JOIN syntax error

mysqlsyntaxouter-join

提问by Sem

Maybe a facepalm for you guys, but as a SQL query newbie, I'm having a syntax issue. Anyone know what's wrong?

也许对你们来说是一个面子,但作为一个 SQL 查询新手,我有一个语法问题。有谁知道怎么了?

SELECT * FROM company C
OUTER JOIN company_address A ON C.company_id = A.company_id
WHERE A.company_id IS NULL

Giving the error:

给出错误:

#1064 - You have an error in your SQL syntax; check the manual that corresponds 
to your MySQL server version for the right syntax to use near 
'OUTER JOIN company_address A ON C.company_id = A.company_id WHERE A.address_id 
' at line 2

回答by valex

In MySQLyou should use LEFT OUTER JOIN or RIGHT OUTER JOIN. There is no just OUTER JOIN. If you need FULL OUTER JOIN in MySql you can use UNION of LEFT JOIN and RIGHT JOIN

在 MySQL 中,您应该使用 LEFT OUTER JOIN 或 RIGHT OUTER JOIN。不只是 OUTER JOIN。如果您需要在 MySql中使用FULL OUTER JOIN,您可以使用 LEFT JOIN 和 RIGHT JOIN 的 UNION

回答by podiluska

Try

尝试

SELECT * FROM company C
LEFT JOIN company_address A ON C.company_id = A.company_id
WHERE A.company_id IS NULL

回答by Anmol

You have to write LEFT JOIN,RIGHT JOIN,INNER JOIN or FULL OUTER JOIN instead of only OUTER JOIN.

你必须写 LEFT JOIN,RIGHT JOIN,INNER JOIN 或 FULL OUTER JOIN 而不仅仅是OUTER JOIN

There is also one error with your table name there shouldn't be spacebetween the letters of a table like this [company C- it should be named as company_C]

你的表名也有一个错误,像这样的表的字母之间不应该有空格[ company C- 它应该被命名为company_C]

I hope that will be work..All the best!

我希望这会奏效..一切顺利!