Jump to content

[SOLVED] DELETE and use !=....?


Teck

Recommended Posts

I'm having trouble deleting some data from a table of mine (about 3500 rows)...

 

Now I have another table "attachments" which has a list of all of the attachments I want to keep basically (about 2500 rows)...

 

What i need to do is delete any row from "forum_attachment" where "attachmentid" is not equal to any value in "attachid" Dunno if that makes any sense...

 

This is the code i have, it will give you a better idea as to what im trying to do

$query = "SELECT attachid FROM attachments ORDER BY id ASC";
$result = mysql_query($query) or die('Error:' . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
$attachid = $row['attachid'];
$query = "DELETE FROM forum_attachment WHERE attachmentid != '$attachid'";
$result = mysql_query($query) or die('Error:' . mysql_error());
}

 

If someone can point me in the right direction i would be grateful...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.