Jump to content


Photo

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


  • Please log in to reply
1 reply to this topic

#1 Gingechilla

Gingechilla
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 08 April 2006 - 07:28 PM

I am trying to get something like this to work:

    $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!";

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)

#2 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 08 April 2006 - 09:48 PM

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

    $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!";

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
ID = 0 OR 4
is always true. It's same with exspresion
(ID = 0) OR TRUE
use
ID = 0 OR ID = 4
or
ID in (1,4)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users