Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: complex query?

  1. #1
    New Coder
    Join Date
    Dec 2003
    Location
    Miami, FL
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    complex query?

    OK, I have this MySQL querry:
    PHP Code:
    @mysql_query("SELECT * FROM `url` WHERE `url1` != '' AND `credits1` != 0 OR `url2` != '' AND `credits2` != 0 OR `url3` != '' AND `credits3` != 0 OR `url4` != '' AND `credits4` != 0 OR `url5` != '' AND `credits5` != 0 OR `url6` != '' AND `credits6` != 0 ORDER BY RAND();"$connection); 
    I want to focus on this:
    PHP Code:
    `url1` != '' AND `credits1` != OR `url2` != '' AND `credits2` != 
    would MySQL interpreat it as
    PHP Code:
    (`url1` != '' AND `credits1` != 0) OR (`url2` != '' AND `credits2` != 0
    Thanks for the help.
    MeGa MaX
    Be the Best, but don't Believe it.

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why post this in the PHP forum?

    I don't know how mySQL would interpret it, so i just use parentheses so that i'm sure it gets evaluated in the order i want it to.

    You should also realise that 0 isn't the same as Null (<-- an empty cell, which is what i suppose you are looking for)

  • #3
    New Coder
    Join Date
    Dec 2003
    Location
    Miami, FL
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I know that 0 != NULL thing... and well, yeah, think I misplaced it

    I just though about, why not actually including the brackets? lol

    thanks anyways
    MeGa MaX
    Be the Best, but don't Believe it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •