Jump to content

DELETE FROM userinfo WHERE ID = 0 OR 4 << Something like this - could it work?


Gingechilla

Recommended Posts

I am trying to get something like this to work:

[code]    $sql = "DELETE FROM youritems WHERE User = 0 OR User = 4";
    $sql2 = "DELETE FROM userinfo WHERE ID = 0 OR 4";
    $result = mysql_query($sql);
    $result = mysql_query($sql2);
    echo "Accounts Reseted!";[/code]

I want to delete accounts who have not been active for more than 200 days (via a strtotime), I put the above together to see if I could delete records with either the values in, however when the script is runs it deletes all of the records in the database, does anyone know how I can fix this?


(I put 0 and 4 as a test, I hope to later replace it with a variable e.g. $userstodelete, and $userstodelete will push in some search results)
Link to comment
Share on other sites

[!--quoteo(post=362844:date=Apr 8 2006, 09:28 PM:name=Gingechilla)--][div class=\'quotetop\']QUOTE(Gingechilla @ Apr 8 2006, 09:28 PM) [snapback]362844[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I am trying to get something like this to work:

[code]    $sql = "DELETE FROM youritems WHERE User = 0 OR User = 4";
    $sql2 = "DELETE FROM userinfo WHERE ID = 0 OR 4";
    $result = mysql_query($sql);
    $result = mysql_query($sql2);
    echo "Accounts Reseted!";[/code]

I want to delete accounts who have not been active for more than 200 days (via a strtotime), I put the above together to see if I could delete records with either the values in, however when the script is runs it deletes all of the records in the database, does anyone know how I can fix this?
(I put 0 and 4 as a test, I hope to later replace it with a variable e.g. $userstodelete, and $userstodelete will push in some search results)
[/quote]
the logical expresion [code]ID = 0 OR 4[/code]is always true. It's same with exspresion [code](ID = 0) OR TRUE[/code]use[code]ID = 0 OR ID = 4[/code]or[code]ID in (1,4)[/code]
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.