I have a table with (amongst others) 2 columns (sayA
and B
) with a primary key
and one with a timestamp
(say C). I would like to delete everything but the last XXX entries (when sorted by the timestamp). Could anyone help me out with the syntax? I guess it should be along the lines of:
DELETE FROM Table WHERE A, B NOT IN (SELECT A, B FROM Table ORDER BY C DESC LIMIT XXX)
Is that correct SQL?
Edit: Somehow this question got closed being a duplicate. The referred question however only has answers that apply to a table which has exactly one primary key (or index) .. how do I expand this to a table where there are two?