Mysql:This version of MySQL doesn’t yet support 錯誤

來源:互聯網
上載者:User

標籤:

This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME 錯誤解決

在一個Mysql運算式中使用巢狀查詢,出現了這個錯誤。原因是內層select語句帶有limit子句。

在網上查了下,有文章指出:

  1. 比如這樣的語句是不能正確執行的。 

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

  3. 但是,只要你再加一層就行。如: 

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

  5. 這樣就可以繞開limit子查詢的問題。 

  6. 問題解決。

後來我發現,上述是解決問題的一個方法,其實還有一個更好的做法,就是把限制條件放到from而非where子句中,就不必出現嵌套再嵌套。

如上例,可以改為:

  1. select * from (select id from table limit 12) as foo;

注意:其實as foo特別重要,如果不寫成from () as xxx的形式,即不給from後的select語句構成表名,那麼最後系統仍會報錯。

Mysql:This version of MySQL doesn’t yet support 錯誤

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.