Unknown column 'rownum' in 'where clause'解决方案
2012-02-16 16:50
531 查看
Unknown column 'rownum' in 'where clause',当在嵌套的查询语句里面用到rownum的时候会遇到这个问题,比如:
SELECT * FROM (select t.id,t.name from USER_INFO t where t.status=0 order by t.EMP_ID desc) _queryForTop where rownum <=10;
这条sql语句查询的时候就会遇到Unknown column 'rownum' in 'where clause'这个错误。
看了下mysql官方的解释,发现在嵌套的查询语句中,当用到where的时候,数据的条数可能还没有被决定, rownum这是根本都还没出来。所以会报错。有遇到这个问题的兄弟们,只能改一改你们的sql语句咯。
mysql官方的链接如下:http://bugs.mysql.com/bug.php?id=38879
http://dev.mysql.com/doc/refman/4.1/en/problems-with-alias.html
原来的那段文字如下:
Standard SQL disallows references to column aliases in a
SELECT * FROM (select t.id,t.name from USER_INFO t where t.status=0 order by t.EMP_ID desc) _queryForTop where rownum <=10;
这条sql语句查询的时候就会遇到Unknown column 'rownum' in 'where clause'这个错误。
看了下mysql官方的解释,发现在嵌套的查询语句中,当用到where的时候,数据的条数可能还没有被决定, rownum这是根本都还没出来。所以会报错。有遇到这个问题的兄弟们,只能改一改你们的sql语句咯。
mysql官方的链接如下:http://bugs.mysql.com/bug.php?id=38879
http://dev.mysql.com/doc/refman/4.1/en/problems-with-alias.html
原来的那段文字如下:
Standard SQL disallows references to column aliases in a
WHEREclause. This restriction is imposed because when the
WHEREclause is evaluated, the column value may not yet have been determined.
相关文章推荐
- Unknown column 'ORGANIZATION_BANK' in 'where clause'
- 关于在eclipse中运行出错的一个小问题 Unknown column 'android' in 'where clause'
- Unknown column '安妮宝贝' in 'where clause'
- java.sql.SQLException:Unknown column 'admin' in 'where clause'错误问题
- Unknown column '??????' in 'where clause'问题
- SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tbl_contact' in 'where clause'.
- 低级错误之 Unknown column 'XX in 'XXclause'
- mysql下出现Unknown column 'xx' in 'on clause'的完全解决方法
- 数据库异常:“Column 'CODE' in where clause is ambiguous”
- php+mysql时报错:Unknown column '' in 'field list'解决方案
- Column 'id' in where clause is ambiguous
- Column 'id' in where clause is ambiguous
- Column 'Email' in where clause is ambiguous
- Column 'id' in where clause is ambiguous
- ERROR 1054 (42S22): Unknown column 'plugin' in 'mysql.user'
- mysql 5.7 版本,密码无法登陆,更改密码时出现ERROR 1054 (42S22): Unknown column 'password' in 'fie
- Unknown column 'conuintoken' in 'field list' 解决办法
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column dd in where clause
- Unknown type &#39;246 in column 3 of 5 in binary-encoded result set
- java.sql.SQLException: Unknown type '246 in column 0 of 1 in binary-encoded result set的解决办法