Skip to content

Instantly share code, notes, and snippets.

@avwave
Created May 1, 2014 09:58
Show Gist options
  • Save avwave/13b8a8ea040dcea91e71 to your computer and use it in GitHub Desktop.
Save avwave/13b8a8ea040dcea91e71 to your computer and use it in GitHub Desktop.
DROP TRIGGER delete_till_max;
CREATE TRIGGER delete_till_max INSERT ON recents WHEN (select count(*) from recents)>49
BEGIN
DELETE FROM recents WHERE recents.id IN (SELECT recents.id FROM recents ORDER BY recents.id limit (select count(*) -49 from recents ));
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment