MySQL. How to remove a limited number of rows from a table?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
26 views
Good day
Please tell me how to remove a limited number of rows from a table in MySQL?
I need to delete 100 rows from a table.
I tried this:
DELETE FROM b_iblock_section WHERE id IN (SELECT ID FROM b_iblock_section WHERE IBLOCK_ID=4 LIMIT 0,100);

But get the error
#1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

Thanks in advance
by | 26 views

4 Answers

0 like 0 dislike
DELETE FROM b_iblock_section WHERE IBLOCK_ID=4 LIMIT 100


You can still get around here
DELETE FROM b_iblock_section WHERE id IN ( SELECT * FROM ( SELECT ID FROM b_iblock_section WHERE IBLOCK_ID=4 LIMIT 0,100 ) as `id` )

if you need is a subquery
by
0 like 0 dislike
If one table works than
DELETE FROM b_iblock_section WHERE IBLOCK_ID=4 LIMIT 0,100


I do not like? to taste you can order by add
by
0 like 0 dislike
According to the description here:
\rhttps://dev.mysql.com/doc/refman/8.0/en/delete.html

It is possible here so:
DELETE FROM b_iblock_section WHERE IBLOCK_ID=4 LIMIT 100;

you can even ORDER BY to specify the order of records to indicate in what order to kill 100 records.
by
0 like 0 dislike
I would have to start determined some hundred records really should be removed.
Most likely, at this stage you find that you want to delete records with ID less than some specific numbers. And all these distortions is not required.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
38,860 users