OR statement

Discussion in 'Databases' started by xamd404, Feb 25, 2011.

  1. #1
    Hello,

    Is there anyway to filter a recordset in PHP using an OR statement?

    for example:
    "SELECT * FROM DB1 WHERE example = %s"

    can i make it so it filters by 2? So something like:

    "SELECT * FROM DB1 WHERE example = %s or example2 = %s"
     
    Last edited: Feb 25, 2011
    xamd404, Feb 25, 2011 IP
  2. jkl6

    jkl6 Peon

    Messages:
    70
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    2nd examples looks ok, why don't you just try and run it against the database?
     
    jkl6, Feb 25, 2011 IP
  3. MaKaVeLLi

    MaKaVeLLi Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes that 2nd set should work perfect so long as you are calling the correct fields.
     
    MaKaVeLLi, Mar 10, 2011 IP
  4. vediovis

    vediovis Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    yes, you can.
     
    vediovis, Mar 22, 2011 IP
  5. kanji

    kanji Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    yes 2 nd query is ok please run it.it gives right output.
     
    kanji, Apr 4, 2011 IP