Multiple WHERE conditions in an SQL query not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hunna03
    New Member
    • Sep 2007
    • 1

    Multiple WHERE conditions in an SQL query not working

    Hey,

    I'm trying to run multiple WHERE statements in a single query but it's not working out. How would I do this?

    [CODE=php]$q1=("SELECT * FROM roster WHERE (Position<='4' AND Terminated='0') ORDER BY Position");[/CODE]
    Last edited by pbmods; Sep 11 '07, 12:39 AM. Reason: Changed [CODE] to [CODE=php].
  • gregerly
    Recognized Expert New Member
    • Sep 2006
    • 192

    #2
    Originally posted by hunna03
    Hey,

    I'm trying to run multiple WHERE statements in a single query but it's not working out. How would I do this?

    Code:
    $q1=("SELECT * FROM roster WHERE (Position<='4' AND Terminated='0') ORDER BY Position");
    I'm not sure it would make a difference, but have you tried the query without the quotes? So:

    [PHP]$q1="SELECT * FROM roster WHERE Position<='4' AND Terminated='0' ORDER BY Position";[/PHP]

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Hi.

      There is nothing wrong with the SQL query, except perhaps that you are quoting integer values. Try removing the quotes and see what happens.

      [CODE=php]$q1="SELECT * FROM roster WHERE (Position<=4 AND Terminated=0) ORDER BY Position";[/CODE]

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Heya, Hunna. Welcome to TSDN!

        Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).

        What do you mean by 'it's not working out'? Are you not getting the results you were expecting? Is MySQL generating an error?

        Comment

        Working...