5 December 2023

While doing a subquery I got this error: "error: SQLSTATE[42000]: Syntax error or access violation: 1235 This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'". To fix this you need to wrap it in an additional subquery. So if you're facing limitations related to the use of LIMIT with subqueries, one approach is to modify your subquery to ensure it returns a limited set of rows without directly using the LIMIT clause. You can achieve this by using appropriate filtering conditions or ordering within the subquery.

Source code viewer
  1. SELECT column1, column2
  2. FROM your_table
  3. WHERE (your_subquery_column1, your_subquery_column2) IN (
  4. -- Additional wrapping for your subquery.
  5. SELECT subquery_column1, subquery_column2
  6. FROM (
  7. -- The original subquery.
  8. SELECT subquery_column1, subquery_column2
  9. FROM your_subquery
  10. ORDER BY some_column
  11. -- End of: The original subquery.
  12. ) AS subquery_alias
  13. -- End of: Additional wrapping for your subquery.
  14. );
Programming Language: MySQL