View Full Version : Deleting old MySQL Records
CuBz
Oct 27th 2007, 5:21 am
I want to delete old records from my forum so that when someone posts a topic it will delete the topic that is used the lessest
The tablename is "topics" and i want to delete "lastreply"
Thanks
theOtherOne
Oct 27th 2007, 5:56 am
DELETE FROM topics ORDER BY lastreply ASC LIMIT 0, 1
nico_swd
Oct 27th 2007, 6:02 am
^^ Maybe I'd add something like WHERE topicid = X as well.
theOtherOne
Oct 27th 2007, 6:13 am
But as I understood from the description, he just wants to delete the least used topic. I don't know whether he already knows the particular topic, but if he doesn't, he can only look for the lowest lastreply. And LIMIT 0, 1 ensures that he only deletes one topic, not all of them ;)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.