I would like to delete the first 100 rows or the last 100 rows in a certain table (ordered by the primary key).
Note: Lots of data is being spooled into this table.<
DELETE FROM table ORDER BY the field DESC|ASC limit 100
SET @first = 1;
delete from mytable
where primKey in (select 1
from myTable
order by
CASE WHEN @first = 1 THEN primKey END ASC,
CASE WHEN @first <> 1 THEN primKey END DESC
limit 100)
for first 100,
DELETE FROM table ORDER BY <field> ASC limit 100
and for last 100,
DELETE FROM table ORDER BY <field> DESC limit 100