我有一个查询
SELECT DISTINCT(n.nid), n.title, n.type, n.status, n.moderate, n.teaser, e.event_start
FROM node n INNER JOIN
node_access na
ON na.nid = n.nid INNER JOIN
event e
USING (nid)
WHERE ((na.grant_view = 1) AND
CONCAT(na.realm, na.gid) IN ('all0','term_access1')) AND
n.status = 1 AND n.moderate = 0 AND e.event_start >= 1400558400
ORDER BY event_start;
它在Windows mysql 4.1.22-community-nt上运行正常,但在ubuntu 5.5.24上它给出了以下错误:
ERROR 1052 (23000): Column 'nid' in from clause is ambiguous
知道为什么会这样吗?假设我无法更改查询,因为它是从开源项目运行的。
答案 0 :(得分:2)
这是from
子句:
FROM node n INNER JOIN
node_access na
ON na.nid = n.nid INNER JOIN
event e
USING (nid)
错误是说引擎不知道nid
是来自node
还是node_access
。如果您可以更改查询,则可以执行以下操作之一:
FROM node n INNER JOIN
node_access na
USING (nid) INNER JOIN
event e
USING (nid)
或
FROM node n INNER JOIN
node_access na
ON na.nid = n.nid INNER JOIN
event e
ON na.nid = e.nid