I have a table, named items.
The structure is:
{name, id, category_id}
There are unknown number of records in the table, I need to limit the number of records for each category to a MAX number, 20 for example.
Pseudo
DELETE FROM items
WHERE (SELECT COUNT(category_id) FROM items)> 20
LIMIT (SELECT COUNT(category_id) FROM items) - 20
1 Answer