Re: Really dumb question... deleting everything but newest100 rows?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If you have a column that gives you the "newness" of each row--I'm
assuming a date here:

delete from my_table order by date_inserted desc limit 100, -1


This should work... I recommend a db backup first :-)


Marco

------------
php|architect - The magazine for PHP Professionals
The monthly worldwide magazine dedicated to PHP programmers
Check us out on the web at http://www.phparch.com

On Sat, 2002-11-23 at 17:38, Leif K-Brooks wrote:
> I know this is a dumb question, but how would I delete everything but 
> the first 100 results returned from a query?  I know I'd use limit, but 
> my mind's going blank as to the exact syntax.
> 
> -- 
> The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux