Re: Delete all but the newest 100 records?

2005-11-08 Thread Scott Noyes
I'd love to get the offset working if possible. Since offset is not in the supported syntax for deletes (see http://dev.mysql.com/doc/refman/5.0/en/delete.html), I think you'll have some trouble with that. You could do something like this: SELECT @theDeadline := `timestamp` FROM `table` ORDER

Re: Delete all but the newest 100 records?

2005-11-07 Thread Jeremy Cole
Hi Brian, Jeremy Cole MySQL Geek, Yahoo! Inc. Desk: 408 349 5104 Yahoo employs MySQL geeks? Always wondered what db that big index runs on... :) Do note that Yahoo! is a lot more than a search engine. :) The big index is not running in MySQL, but a whole lot more is. And yes, we

Re: Delete all but the newest 100 records?

2005-11-07 Thread Brian Dunning
On Nov 6, 2005, at 6:05 PM, Jeremy Cole wrote: DELETE FROM tbl ORDER BY ts DESC LIMIT 100, 99; That's exactly needed: I was not aware of the OFFSET option. So I tried this, which appears correct to me: DELETE FROM table WHERE field='somevalue' ORDER BY timestamp DESC LIMIT

Re: Delete all but the newest 100 records?

2005-11-07 Thread Brian Dunning
On Nov 7, 2005, at 11:04 AM, Scott Noyes wrote: delete from x where ID not in (select ID from x order by timestamp desc limit 100); It's a good suggestion, I'm just shying away from it because it seems more resource intensive than using an offset, and my ISP is super anal about

Re: Delete all but the newest 100 records?

2005-11-07 Thread Brian Dunning
Interesting thought. I just tried it with and even 999 - same error! I'm sure that 999 records is not too large for MySQL... :) :) On Nov 7, 2005, at 4:52 PM, Joseph Cochran wrote: The quoted line is 99 but you're using , which I presume is too big for the system to

Re: Delete all but the newest 100 records?

2005-11-07 Thread The Nice Spider
On Nov 7, 2005, at 11:04 AM, Scott Noyes wrote: delete from x where ID not in (select ID from x order by timestamp desc limit 100); It's a good suggestion, I'm just shying away from it because it seems more resource intensive than using an offset, and my ISP is super anal about

Re: Delete all but the newest 100 records?

2005-11-06 Thread Jerry Swanson
all but the newest 100 records from a table. I have a timestamp field. I can't figure out how to do this in a single SQL statement - can anyone help? Thanks! -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]

Re: Delete all but the newest 100 records?

2005-11-06 Thread Björn Persson
söndagen den 6 november 2005 16:15 skrev Brian Dunning: I'd like to delete all but the newest 100 records from a table. I have a timestamp field. I can't figure out how to do this in a single SQL statement - can anyone help? Thanks! I'd try something like this: delete from x where ID

Re: Delete all but the newest 100 records?

2005-11-06 Thread Brian Dunning
The problem is the most recent 100 records won't be sequential. There are records with many different identifiers, in random order mixed with other records that I don't want deleted, and each time I do this I'm going to be limiting each subset of identified records to only the most recent

Re: Delete all but the newest 100 records?

2005-11-06 Thread Jeremy Cole
Hi Brian, I'd like to delete all but the newest 100 records from a table. I have a timestamp field. I can't figure out how to do this in a single SQL statement - can anyone help? Thanks! This should work: DELETE FROM tbl ORDER BY ts DESC LIMIT 100, 99; Note that ORDER BY and LIMIT

Re: Delete all but the newest 100 records?

2005-11-06 Thread Brian Dunning
On Nov 6, 2005, at 6:05 PM, Jeremy Cole wrote: Jeremy Cole MySQL Geek, Yahoo! Inc. Desk: 408 349 5104 Yahoo employs MySQL geeks? Always wondered what db that big index runs on... :) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: