SnapOff Racing
03-15-2010, 07:02 PM
I was wondering if anyone had any suggestions of a script or a query that I could use that would allow me to delete orphan attachments from my database. I can usually whip up a query that will do what I want it to do except in this case I am not having much luck mainly because with this query I am assuming I am gonna have to use the thread/post table as some sorta reference for deleting orphan attachments from the attachment table.
I found this query when I searched the forums but it's for deleting all attachments in a specific forum. From looking at the query though it looks like it might be almost what I am looking for.
DELETE FROM attachment USING attachment, post, thread WHERE attachment.postid = post.postid AND thread.threadid = post.threadid AND thread.forumid = X
Anyone have any ideas?
I found this query when I searched the forums but it's for deleting all attachments in a specific forum. From looking at the query though it looks like it might be almost what I am looking for.
DELETE FROM attachment USING attachment, post, thread WHERE attachment.postid = post.postid AND thread.threadid = post.threadid AND thread.forumid = X
Anyone have any ideas?