`
flex_莫冲
  • 浏览: 1103925 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

MySQL 1054错误 Unknown column .... in 'on clause'

 
阅读更多
提示:

ERROR 1054 (42S22): Unknown column ... in 'on clause'

原因:

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

例:

Sql代码 
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,要把联合的表用括号包含起来才行:

Sql代码 
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 
但是HQL生成就是这样的语句,怎么办呢?我们可以改变HQL的写法来达成生成另一种SQL语句,以避免这种BUG的出错
把select (c.id, a.id, b.id) from C c Left join c.a a Left join c.b b
则会生成

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

这样的话mysql下就不会出错了。

以上文章了来自网络。
分享到:
评论

相关推荐

    MySQL5.7更改密码时出现ERROR 1054 (42S22)的解决方法

    登录时提示密码错误,安装的时候并没有更改密码,后来通过免密码登录的方式更改密码,输入update mysql.user set password=password(‘root’) where user=’root’时提示ERROR 1054 (42S22): Unknown column ...

    Delphi7.1 Update

    * In the Project Manager, units are incorrectly displayed in the order that they are listed in the USES clause, rather than alphabetically. * Using collections containing component references and ...

    php代码出现错误分析详解第1/2页

    错误信息为 Error 1054: Unknown column 'tuijian' in 'where clause'。解决方案是检查数据库中的表结构,确保所有的字段名都是正确的。 三、服务器内存限制错误 当PHP脚本使用的内存超过了php.ini中设定的限制时,...

    乐优商城.xmind

    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'idASC' in 'order clause' 错误:(desc ? "DESC" : "ASC"); 正确:(desc ? " DESC" : " ASC"); 字符串空格问题 新增 Controller...

    T简易个人网站系统 v1.2

    错误:Unknown column 'gusetVerify' in 'where clause'2.回复留言时,显示的回复者是作者的名字。安装步骤:1. 把本程序上传到你的空间,本程序存放位置只能为网站根目录或二级目录。注意:FCKeditor 这个是编辑器...

Global site tag (gtag.js) - Google Analytics