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
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);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: 0SELECT * FROM reviews WHERE product_id IN (SELECT id FROM products ORDER BY sold DESC LIMIT 2);ERROR 1235 (42000): This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'SELECT id FROM products ORDER BY sold DESC LIMIT 2;+----+
| 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.
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;+----+------------+-------+
| 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
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');Query OK, 0 rows affected (0.02 sec)
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0DELETE FROM logs WHERE id IN (SELECT id FROM logs ORDER BY created LIMIT 2);ERROR 1235 (42000): This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'SELECT id, created FROM logs ORDER BY created LIMIT 2;+----+------------+
| id | created |
+----+------------+
| 1 | 2026-01-01 |
| 2 | 2026-02-01 |
+----+------------+
2 rows in set (0.01 sec)DELETE FROM logs ORDER BY created LIMIT 2;
SELECT * FROM logs ORDER BY id;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
CREATE TABLE members (login_id VARCHAR(20) COLLATE utf8mb4_unicode_ci PRIMARY KEY, name VARCHAR(20));
INSERT INTO members VALUES ('kim01', 'Kim');Query OK, 0 rows affected (0.02 sec)
Query OK, 1 row affected (0.00 sec)CREATE PROCEDURE find_member(IN p_id VARCHAR(20) COLLATE utf8mb4_unicode_ci)
SELECT name FROM members WHERE login_id = p_id;ERROR 1235 (42000): This version of MySQL doesn't yet support 'COLLATE with no CHARACTER SET in SP parameters, RETURNS, DECLARE'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;Query OK, 0 rows affected (0.00 sec)CALL find_member('kim01');+------+
| 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