943,682 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 643
  • PHP RSS
Jun 12th, 2009
0

how do i do three WHERE clauses with php (mysql)

Expand Post »
this code isnt workin:
PHP Syntax (Toggle Plain Text)
  1. $newer = mysql_query("DELETE FROM messages WHERE id = '$rawr', user = '$rew', read = '$roll'");
this code works:
PHP Syntax (Toggle Plain Text)
  1. $newer = mysql_query("DELETE FROM messages WHERE id = '$rawr' AND user = '$rew'");
the variable is the same that is included in the first, so its not the variable. i think i dont know how to have three of them cause i know that for two i can use the AND instead of commas.
please help i googled it and couldnt figure it out
Reputation Points: 15
Solved Threads: 7
Posting Pro in Training
SKANK!!!!! is offline Offline
428 posts
since Apr 2009
Jun 12th, 2009
0

Re: how do i do three WHERE clauses with php (mysql)

it is not working becasue you are using , instead of and
PHP Syntax (Toggle Plain Text)
  1. $newer = mysql_query("DELETE FROM messages WHERE id = '$rawr' AND user = '$rew' AND read = '$roll'");
this should work
Reputation Points: 31
Solved Threads: 5
Light Poster
yilmazhuseyin is offline Offline
48 posts
since Oct 2006
Jun 15th, 2009
0

Re: how do i do three WHERE clauses with php (mysql)

so i can use more than two ands? can i use like 5 ands?
Reputation Points: 15
Solved Threads: 7
Posting Pro in Training
SKANK!!!!! is offline Offline
428 posts
since Apr 2009
Jun 15th, 2009
0

Re: how do i do three WHERE clauses with php (mysql)

You can use as many ANDs and ORs as you like, with as many parenthesis as you like to create as many logical sub-groupings as you like:
PHP Syntax (Toggle Plain Text)
  1. a AND b AND (c OR (d AND e) OR (f AND g)) ...
but be aware that at some point you cross a line where you should probably re-examine your join criteria and ask yourself why you're having to specify so much in a WHERE clause.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 838
Posting Genius
Ezzaral is offline Offline
6,757 posts
since May 2007
Jun 15th, 2009
0

Re: how do i do three WHERE clauses with php (mysql)

oh ok ive only had to specify about 3-4 tops in a where clause...
thanks. ive never user parenthesis yet.
Reputation Points: 15
Solved Threads: 7
Posting Pro in Training
SKANK!!!!! is offline Offline
428 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP parsing error with html tag... does this mean I have misbalanced braces?
Next Thread in PHP Forum Timeline: PostBack method on Page Refresh





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC