I ran into an old MySQL limitation while experimenting with subqueries and wanted to document it because it can be confusing when you first hit it.

Using the sample world database, this kind of query worked:

1
2
3
4
5
SELECT Name
FROM city
GROUP BY Name
HAVING MAX(Population) > 10000
LIMIT 20;

But when I tried to use that same pattern inside a DELETE ... WHERE Name IN (...) statement:

1
2
3
4
5
6
7
8
DELETE FROM city
WHERE Name IN (
  SELECT Name
  FROM city
  GROUP BY Name
  HAVING MAX(Population) > 10000
  LIMIT 20
);

MySQL responded with:

1
This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

At the time, the practical fallback was to resolve the values first and then run a query like:

1
DELETE FROM city WHERE Name IN ('name1', 'name2', 'name3');

It was a small issue, but one worth remembering if you are working with older MySQL behavior or trying to understand why a query structure that seems reasonable still fails.