Jump to content

Archived

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

Guest PcGamerz13

Mysql WHERE help

Recommended Posts

Guest PcGamerz13
How do yoy make it Search 5 fields and only shows Win_Tie_Lose='Win'
[code]$sql5=mysql_query("SELECT * FROM clan_matches WHERE Member_1='$Member_Gamer_Tag' OR Member_2='$Member_Gamer_Tag' OR Member_3='$Member_Gamer_Tag' OR Member_4='$Member_Gamer_Tag' OR Member_5='$Member_Gamer_Tag' AND Win_Tie_Lose='Win'");[/code]

Share this post


Link to post
Share on other sites
Two ways

1 ) Use "()" to separate OR's from the AND

[code]SELECT * FROM clan_matches
      WHERE ((Member_1='$Member_Gamer_Tag')
      OR (Member_2='$Member_Gamer_Tag')
      OR (Member_3='$Member_Gamer_Tag')
      OR (Member_4='$Member_Gamer_Tag')
      OR (Member_5='$Member_Gamer_Tag'))
      AND Win_Tie_Lose='Win'[/code]

2 ) Use "IN(list)" instead of the OR's

[code]SELECT * FROM clan_matches
      WHERE '$Member_Gamer_Tag' IN (Member_1, Member_2,Member_3, Member_4,Member_5)
      AND Win_Tie_Lose='Win'[/code]

Share this post


Link to post
Share on other sites

×

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.