View Full Version : A mySQL query to remove old attachments
waddy
Mon 11th Feb '02, 7:51am
Hi
Im trying to write a mySQL query to delete attachments older than a certain date..
For example : delete attachments posted before February 1st
Im cannot get it to work , i dont understand the dateline in VBulletin Attachment table
Can anyone write a working SQL query for me to use, i think alot of people will get use from it
thanks
RINCE
Mon 11th Feb '02, 8:20am
The dateline field contains a unix timestamp.
waddy
Mon 11th Feb '02, 8:30am
Hmmm sorry but thats as clear as mud :)
Im not a Unix guy or a SQL programmer, I just need help with a query to reduce my Database by 40MB before it dies
Pogo
Mon 11th Feb '02, 8:45am
select * from attachment where dateline < UNIX_TIMESTAMP('yyyy-mm-dd hh:mm:ss')
This way it will show you all attachments before the date you enter.
Change select to delete and you can delete them.
waddy
Mon 11th Feb '02, 8:52am
Thanks Pogo ... :)
Thats excellent ..... i appreciate your help ....
waddy
Mon 11th Feb '02, 9:09am
It Doesnt seem to like that SQL statement
---------------------------------------------
Error
SQL-query :
delete * from attachment where dateline < UNIX_TIMESTAMP('2002-01-15 02:00:00')
MySQL said:
You have an error in your SQL syntax near '* from attachment where dateline < UNIX_TIMESTAMP('2002-01-15 02:00:00')
-------------------------------------------------
IM using phpMyAdmin 2.2.1
Pogo
Mon 11th Feb '02, 9:19am
My fault :(
delete from attachment where dateline < UNIX_TIMESTAMP('2002-01-15 02:00:00')
waddy
Mon 11th Feb '02, 9:24am
No Pogo , my fault for being Dumb :(
i was just reading about it but was worried to use it , "just in case"
Thanks very much
Waddy
Note: I have 1050 people waiting for activation, obviously they have used a fake email ... is it safe to EMPTY the whole lot in the table
"useractivation"
vBulletin® v3.8.0 Beta 4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.