简体   繁体   中英

MySql Outer Join Error 1064

I am having an error trying to outer join 4 tables, 2 x 2, to match the missing links between both I want to show also those rows without match.

This query works fine:

select
  r.name    AS r,
  a.name    AS a,
  f.name    AS f
from Field f
     join Order o 
    on f.f2o = o.oid
     join Resource r 
    on r.name = o.name
     join Attribute a 
    on a.a2r= r.oid and f.name = a.name;

But if I use left or outer, it no longer works. This does not work:

select
  r.name    AS r,
  a.name    AS a,
  f.name    AS f
from Field f
     join Order o 
    on f.f2o = o.oid
     join Resource r 
    on r.name = o.name
     outer join Attribute a             -- <--- here is the issue
    on a.a2r= r.oid and f.name = a.name;

Returning

1 queries executed, 0 success, 1 errors, 0 warnings

Query: select r.name AS r, a.name AS a, f.name AS f, oi.action AS action from t_m_prod_action_oitem_fld f join t_m_prod_action_oitem oi...

Error Code: 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 t_m_attr a on a.attr2rfs = r.oid and f.name = a.name LIMIT 0, 1000' at line 11

Thanks in advance

There's no such thing. Either use a LEFT JOIN , a RIGHT JOIN or emulate a FULL OUTER JOIN using the union of the LEFT JOIN and RIGHT JOIN .

JOINs are very different across different SQL dialects. Some call the joins slightly different, some don't have specific joins, some support them using a different syntax (such as not having CROSS JOIN but you can still do a CROSS JOIN using JOIN without an ON condition). Always read the docs of the SQL dialect you're using.

Some people use outer join to mean full outer join where as other people use outer join as a category that has the three left , right and full outer joins. But MySQL doesn't have a full outer join .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM