MySQL 5 left join unknown column

前端 未结 3 2026
有刺的猬
有刺的猬 2021-02-13 16:47

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          


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-13 17:29

    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 
    

    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
    

    As you can see, there is no source for e.email inside the parentheses: that's why it could not be resolved.

提交回复
热议问题