本文介绍了MySQL 5左联接未知列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在mysql 4.1中有以下查询,但在5.0中却没有:
I had the below query working in mysql 4.1, but does not in 5.0:
SELECT * FROM email e, event_email ee LEFT JOIN member m on m.email=e.email WHERE ee.email_id = e.email_id错误: 1054(子句"中的未知列"e.email")
The error: 1054 (Unknown column 'e.email' in 'on clause')
推荐答案您只能在ON子句中引用以前与JOIN子句连接的表.
You can only refer the tables previously joined with the JOIN clause in the ON clause.
SELECT * FROM email e JOIN event_email ee ON ee.email_id = e.email_id LEFT JOIN member m ON m.email = e.email如果我在原始查询中的ANSI JOINS周围加上括号,则可以更好地说明这一点:
This can be illustrated better if I put the parentheses around the ANSI JOINS in your original query:
SELECT * FROM email e, ( event_email ee LEFT JOIN member m ON m.email = e.email ) WHERE ee.email_id = e.email_id如您所见,括号内没有e.email的来源:这就是为什么它无法解析的原因.
As you can see, there is no source for e.email inside the parentheses: that's why it could not be resolved.
更多推荐
MySQL 5左联接未知列
发布评论