mysql查询Unknown column ‘xxx’ in ‘on clause’问题解决

mysql查询出现提示Unknown column ‘xxx’ in ‘on clause’的问题原因为:

MySQL5.0 Bug, 要把联合的表用括号包含起来才行:

SELECT (c.id, a.id, b.id) FROM A a, B b LEFT JOIN C c ON c.a_id = a.a_id AND c.b_id = b.b_id

这句话执行应该是没有错误的,但是Mysql 5 下执行则会出错。

因为mysql下有这样一个BUG,要把联合的表用括号包含起来才行:

SELECT (c.id, a.id, b.id) FROM (A a, B b) LEFT JOIN C c ON c.a_id = a.a_id AND c.b_id = b.b_id