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
https://forums.phpfreaks.com/topic/89150-solved-delete-and-use/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.