gpt4 book ai didi

MySql 外连接错误 1064

转载 作者:行者123 更新时间:2023-11-29 10:08:29 24 4
gpt4 key购买 nike

我在尝试外部联接 4 个表(2 x 2)以匹配两个表之间缺少的链接时遇到错误,我还想显示那些不匹配的行。

这个查询工作正常:

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;

但是如果我使用 left 或 external,它就不再起作用了。这不起作用:

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;

返回

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

提前致谢

最佳答案

没有这样的事情。使用 LEFT JOINRIGHT JOIN 或使用 LEFT JOIN 的并集模拟 FULL OUTER JOIN RIGHT JOIN

不同 SQL 方言的 JOIN 有很大不同。有些对连接的调用略有不同,有些没有特定的连接,有些使用不同的语法支持它们(例如没有 CROSS JOIN 但您仍然可以执行 CROSS JOIN > 使用 JOIN 而不使用 ON 条件)。请务必阅读您正在使用的 SQL 方言的文档。

有些人使用 outer join 来表示 完全外连接,而其他人则使用 outer join 作为具有三个 的类别>leftrightfull outer 连接。但 MySQL 没有全外连接

关于MySql 外连接错误 1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51445967/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com