I have a table with unknow number of rows in it. I need to remove all the rows, except a fixed number of records.
Example: Table 1 has 439 rows. I need to keep 200 rows randomly and delete others.
The "logic way" is:
DELETE FROM table_1
WHERE id NOT IN (SELECT id FROM table_1 ORDER BY RAND() LIMIT 200)```
But mariaDB says
You cannot use LIMIT in subquery ...
How I can do it? Thanks in advance!