MySQL does not support the use of the limit solution in subqueries

Source: Internet
Author: User

MySQL does not support the use of the limit solution in subqueries

This version of MySQL doesn ' t yet support ' LIMIT & in/all/any/some subquery '

The use of the Limit keyword in a subquery is not supported in the literal sense.

After searching, an alternative solution was found.


is to add a sub-query to the outer layer of the limit subquery.

Like what:

The original SQL statement that could have been an error is: Select *from cidy where ID in (select ID from cidy limit 0,10);

The modified SQL is: Select *from cidy where ID in (select ID from cidy limit 0,10);

Tested, modified SQL statement execution times error: Every derived table must has its own alias

The literal meaning of the error is: Aliases required

As you can see from the SQL statement above, our extra layer of SQL not only has no alias and no table name, is there a problem here? You'll find out if you test it.

The modified SQL statement is: SELECT *from cidy where ID in (SELECT ID from (SELECT ID from Cidy limit 0,10) as CD);

After testing, as we have thought, finally succeeded.

MySQL does not support the use of the limit solution in subqueries

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.