SELECT a.data FROM Authentications a, Authentications b LEFT JOIN Authentications c ON a.id = c.id
为什么此查询会产生"#1054 - 未知列' a.id'在' on条款'"当
SELECT a.data FROM Authentications a LEFT JOIN Authentications c ON a.id = c.id
没关系?
答案 0 :(得分:7)
问题是您正在混合JOIN语法,因此您使用的别名在ON
条件下不可用。你不应该混合使用JOIN语法。
您的查询应该是:
SELECT a.data
FROM Authentications a
CROSS JOIN Authentications b
LEFT JOIN Authentications c
ON a.id = c.id
或者如果您加入b
,那么您将使用:
SELECT a.data
FROM Authentications a
INNER JOIN Authentications b
on a.id = b.id
LEFT JOIN Authentications c
ON a.id = c.id
JOIN
的优先级高于逗号,因此a
的别名ON
不可用。
答案 1 :(得分:0)
首先查询您将b加入c并将条件置于a。
没有加入
答案 2 :(得分:0)
'on'子句必须使用正在连接的表中的列 - 类似于 选择a.data 来自身份验证a,身份验证b LEFT JOIN认证c ON b.id = c.id. 其中a.id = b.id
或类似的东西