MySQL 5左联接未知列 [英] MySQL 5 left join unknown column

查看:68
本文介绍了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左联接未知列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆