Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL OUTER JOIN syntax error

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

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
like image 650
Sem Avatar asked Sep 05 '25 03:09

Sem


1 Answers

In MySQL you 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

like image 79
valex Avatar answered Sep 07 '25 17:09

valex