MySQL 8.4Lab-verified · 2026-11-30

MySQL ERROR 1235 (42000): This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

The query used a feature MySQL does not support, most often LIMIT inside an IN subquery.

MySQL 8.4.13
1235 (42000): This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

Jump to a cause

  1. 01SELECT … WHERE col IN (SELECT … ORDER BY … LIMIT n)
  2. 02DELETE … WHERE id IN (SELECT … LIMIT n) to delete the oldest rows
  3. 03COLLATE without CHARACTER SET on a stored procedure parameter

Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-30 · container image mysql:8.4

ERROR 1235 is MySQL's message for a feature it does not implement. The part in quotes tells you which one. The most common is 'LIMIT & IN/ALL/ANY/SOME subquery': you cannot put LIMIT in a subquery used with IN, even on MySQL 8.4.

Below are three cases reproduced on MySQL 8.4. The first two are the LIMIT case, in SELECT and DELETE. The third gives a different quoted text, 'COLLATE with no CHARACTER SET in SP parameters, RETURNS, DECLARE'. Each comes with the rewritten SQL that actually ran.

01SELECT … WHERE col IN (SELECT … ORDER BY … LIMIT n)

Getting reviews of the two best-selling products with WHERE product_id IN (SELECT id FROM products ORDER BY sold DESC LIMIT 2) fails with ERROR 1235. The subquery alone runs fine and returned ids 3 and 1.

Move the subquery into a derived table and JOIN it: JOIN (SELECT id FROM products ORDER BY sold DESC LIMIT 2) top2 ON top2.id = r.product_id. LIMIT is allowed in a derived table, and the query returned the 3 reviews of products 3 and 1.

Setup
Setuprun as lab_a
CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR(20), sold INT);
INSERT INTO products VALUES (1, 'Pen', 120), (2, 'Note', 80), (3, 'Bag', 300), (4, 'Cup', 50);
CREATE TABLE reviews (id INT PRIMARY KEY, product_id INT, score INT);
INSERT INTO reviews VALUES (1, 1, 5), (2, 3, 4), (3, 4, 3), (4, 3, 5);
OUTPUT
Query OK, 0 rows affected (0.02 sec)

Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0

Query OK, 0 rows affected (0.02 sec)

Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0
Reproducerun as lab_a
SELECT * FROM reviews WHERE product_id IN (SELECT id FROM products ORDER BY sold DESC LIMIT 2);
✕ ERROR
ERROR 1235 (42000): This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
Checkrun as lab_a
SELECT id FROM products ORDER BY sold DESC LIMIT 2;
OUTPUT
+----+
| id |
+----+
|  3 |
|  1 |
+----+
2 rows in set (0.00 sec)

If the subquery can return the same id twice, add DISTINCT inside it, or the JOIN will repeat rows.

After the fixrun as lab_a
SELECT r.* FROM reviews r JOIN (SELECT id FROM products ORDER BY sold DESC LIMIT 2) top2 ON top2.id = r.product_id ORDER BY r.id;
✓ SUCCESS
+----+------------+-------+
| id | product_id | score |
+----+------------+-------+
|  1 |          1 |     5 |
|  2 |          3 |     4 |
|  4 |          3 |     5 |
+----+------------+-------+
3 rows in set (0.00 sec)

02DELETE … WHERE id IN (SELECT … LIMIT n) to delete the oldest rows

Deleting the two oldest log rows with DELETE FROM logs WHERE id IN (SELECT id FROM logs ORDER BY created LIMIT 2) fails with the same ERROR 1235.

A single-table DELETE accepts ORDER BY and LIMIT directly: DELETE FROM logs ORDER BY created LIMIT 2; returned Query OK, 2 rows affected, and rows 3 and 4 were left. Running the subquery alone as a SELECT first showed which rows (1 and 2) would go.

Setup
Setuprun as lab_a
CREATE TABLE logs (id INT PRIMARY KEY, created DATE);
INSERT INTO logs VALUES (1, '2026-01-01'), (2, '2026-02-01'), (3, '2026-03-01'), (4, '2026-04-01');
OUTPUT
Query OK, 0 rows affected (0.02 sec)

Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0
Reproducerun as lab_a
DELETE FROM logs WHERE id IN (SELECT id FROM logs ORDER BY created LIMIT 2);
✕ ERROR
ERROR 1235 (42000): This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
Checkrun as lab_a
SELECT id, created FROM logs ORDER BY created LIMIT 2;
OUTPUT
+----+------------+
| id | created    |
+----+------------+
|  1 | 2026-01-01 |
|  2 | 2026-02-01 |
+----+------------+
2 rows in set (0.01 sec)
After the fixrun as lab_a
DELETE FROM logs ORDER BY created LIMIT 2;
SELECT * FROM logs ORDER BY id;
✓ SUCCESS
Query OK, 2 rows affected (0.00 sec)

+----+------------+
| id | created    |
+----+------------+
|  3 | 2026-03-01 |
|  4 | 2026-04-01 |
+----+------------+
2 rows in set (0.00 sec)

03COLLATE without CHARACTER SET on a stored procedure parameter

CREATE PROCEDURE find_member(IN p_id VARCHAR(20) COLLATE utf8mb4_unicode_ci) fails with ERROR 1235, but the quoted text is different: 'COLLATE with no CHARACTER SET in SP parameters, RETURNS, DECLARE'. In procedure parameters, function RETURNS and DECLARE, COLLATE needs a CHARACTER SET next to it.

Writing VARCHAR(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci created the procedure, and CALL find_member('kim01') returned Kim.

Setup
Setuprun as lab_a
CREATE TABLE members (login_id VARCHAR(20) COLLATE utf8mb4_unicode_ci PRIMARY KEY, name VARCHAR(20));
INSERT INTO members VALUES ('kim01', 'Kim');
OUTPUT
Query OK, 0 rows affected (0.02 sec)

Query OK, 1 row affected (0.00 sec)
Reproducerun as lab_a
CREATE PROCEDURE find_member(IN p_id VARCHAR(20) COLLATE utf8mb4_unicode_ci)
SELECT name FROM members WHERE login_id = p_id;
✕ ERROR
ERROR 1235 (42000): This version of MySQL doesn't yet support 'COLLATE with no CHARACTER SET in SP parameters, RETURNS, DECLARE'
Fixrun as lab_a
CREATE PROCEDURE find_member(IN p_id VARCHAR(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci)
SELECT name FROM members WHERE login_id = p_id;
OUTPUT
Query OK, 0 rows affected (0.00 sec)
After the fixrun as lab_a
CALL find_member('kim01');
✓ SUCCESS
+------+
| name |
+------+
| Kim  |
+------+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

FAQ

How do I fix "doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'"?

Turn the IN subquery into a derived table and JOIN it: JOIN (SELECT id … LIMIT 2) t ON t.id = …. On MySQL 8.4 that ran and returned the expected rows.

Does MySQL 8 support LIMIT in an IN subquery?

No. MySQL 8.4.13, used on this page, still gave ERROR 1235 for both SELECT and DELETE with IN (… LIMIT 2).

How do I delete the oldest N rows in MySQL?

DELETE FROM logs ORDER BY created LIMIT 2; A single-table DELETE takes ORDER BY and LIMIT, so no subquery is needed.

What does "COLLATE with no CHARACTER SET in SP parameters" mean?

A procedure parameter, RETURNS or DECLARE has COLLATE without CHARACTER SET. Write both, for example VARCHAR(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13