zoukankan      html  css  js  c++  java
  • Mysql:Error Code 1235,This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME 错误解决

    This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME 错误解决

    这次国庆节回来后的测试中,在一个Mysql表达式中使用嵌套查询,出现了这个错误。原因是内层select语句带有limit子句。
    在网上查了下,有文章指出:

    比如这样的语句是不能正确执行的。 

    select * from table where id in (select id from table limit 12); 

    但是,只要你再加一层就行。如: 

    select * from table where id in (select t.id from (select * from table limit 12)as t) 

    这样就可以绕开limit子查询的问题。 

    问题解决。

    后来我发现,上述是解决问题的一个方法,其实还有一个更好的做法,就是把限制条件放到from而非where子句中,就不必出现嵌套再嵌套。
    如上例,可以改为:
    select * from (select id from table limit 12) as foo;

    注意:其实as foo特别重要,如果不写成from () as xxx的形式,即不给from后的select语句构成表名,那么最后系统仍会报错。

    参考http://blog.chinaunix.net/uid-22414998-id-2945656.html

  • 相关阅读:
    The model backing the 'XXX' context has changed 错误
    MVC5+EF6 入门完整教程四
    MVC5 + EF6 完整入门教程三
    MVC5 + EF6 入门完整教程二
    每日总结9.11
    setTextColor的几个注意事项
    selector使用注意事项
    每日总结9.9
    android popWindow使用注意事项
    有关TextView的drawaleTop属性
  • 原文地址:https://www.cnblogs.com/azhqiang/p/5942093.html
Copyright © 2011-2022 走看看