I'm trying to do this:
DELETE FROM table WHERE uid='5' AND id NOT IN (SELECT * FROM (SELECT id FROM table WHERE uid='5' ORDER BY id DESC LIMIT 20) AS TAB)
and in case you were wondering... The above query will look at table, and the where the UID = 5, it will delete all but the last 20 records.
I know I could easily do this with perl, and a few queries... However letting mysql do it all in one seems so much more.... right...
Any ideas on this would be extremely helpful!
Thanks!
AlexJ
DELETE FROM table WHERE uid='5' AND id NOT IN (SELECT * FROM (SELECT id FROM table WHERE uid='5' ORDER BY id DESC LIMIT 20) AS TAB)
and in case you were wondering... The above query will look at table, and the where the UID = 5, it will delete all but the last 20 records.
I know I could easily do this with perl, and a few queries... However letting mysql do it all in one seems so much more.... right...
Any ideas on this would be extremely helpful!
Thanks!
AlexJ