Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How to use GT:SQL module to do this query/delete....

Quote Reply
How to use GT:SQL module to do this query/delete....
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
Subject Author Views Date
Thread How to use GT:SQL module to do this query/delete.... AlexJ 4040 Jun 3, 2010, 12:09 PM
Thread Re: [AlexJ] How to use GT:SQL module to do this query/delete....
brewt 3904 Jun 3, 2010, 1:00 PM
Thread Re: [brewt] How to use GT:SQL module to do this query/delete....
AlexJ 3907 Jun 3, 2010, 1:59 PM
Thread Re: [AlexJ] How to use GT:SQL module to do this query/delete....
Andy 3910 Jun 3, 2010, 3:18 PM
Post Re: [Andy] How to use GT:SQL module to do this query/delete....
AlexJ 3880 Jun 4, 2010, 6:01 AM