MySQL does not support the use of limit solutions in subqueries

Source: Internet
Author: User


Today in the processing of a movie site data, need to change part of the content, because this site has too many movies, a piece of processing is very difficult, so want to start from a part of the analysis, and then use to limit. At this time the MySQL error:

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

The literal meaning is that the limit keyword is not supported for use in subqueries.

After searching, we found an alternative solution.


is to add a layer of subqueries to the limit of the subquery.

Like what:

The SQL statement that could have been an error was: 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 (SELECT ID from Cidy limit 0,10));

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

The literal meaning of the error is: Need alias

From the above SQL statement, we can see that the extra layer of SQL not only has no alias, no table name, will it be a problem here? The test will know

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 thought, finally succeeded.

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.