开发者

why does my full join query fail?

开发者 https://www.devze.com 2023-04-03 10:13 出处:网络
I have this query: SELECT *, default_insurance.company AS company FROM (default_insurance) JOIN default_gruppe_rel

I have this query:

SELECT *, default_insurance.company AS company
FROM (default_insurance)
JOIN default_gruppe_rel
     ON default_gruppe_rel.uid = default_insurance.uid
JOIN default_profiles
     ON defa开发者_如何学Goult_insurance.uid = default_profiles.id
WHERE `kontakt` = '1' 

Now I get a resultset from that, but If I want to get results where there are not join matches , and only change this query by changing the first join type to FULL like this

SELECT *, default_insurance.company AS company
FROM (default_insurance)
FULL JOIN default_gruppe_rel
    ON default_gruppe_rel.uid = default_insurance.uid
JOIN default_profiles
    ON default_insurance.uid = default_profiles.id
WHERE `kontakt` = '1' 

I get an error saying: 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 'FULL JOIN default_gruppe_rel ON default_gruppe_rel.uid = default_insurance.uid J' at line 1

why is that? is the FULL JOIN unkown to my MYSQL version? Has it been deprecated?


MySQL does not support a FULL JOIN. See the MySQL docs for a few workarounds as provided in the user comments.


FULL JOIN only works on some RDBMS...try LEFT OUTER JOIN/LEFT JOIN in order to get all records in the first table and all matches from the subsequent table.

You can also try a CROSS JOIN, which isn't really a join, but rather returns the cartesian product (ie, all possible combinations) of the 'joined' tables.


...LEFT JOIN...
UNION ALL
...RIGHT JOIN...
0

精彩评论

暂无评论...
验证码 换一张
取 消