1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

MYSQL OR Query

Discussion in 'MySQL' started by Weirfire, Jun 7, 2005.

  1. #1
    I'm wanting to do something like

    mysql_query("SELECT * FROM Table WHERE value='true' OR value2='true' OR value3='true'");

    but I'm not sure what the correct syntax should be for the 'OR'. I've tried using the exact word OR but it doesnt seem to like it.

    Any ideas?
     
    Weirfire, Jun 7, 2005 IP
  2. sadcox66

    sadcox66 Spirit Walker

    Messages:
    496
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What error are you getting ? Make sure value1..n are declared boolean in db

    Try
    mysql_query("SELECT * FROM Table WHERE (value='true') OR (value2='true') OR (value3='true') ");

    If you have phpMyAdmin - Use it's query builder to build the query for you.
     
    sadcox66, Jun 7, 2005 IP
    Weirfire likes this.
  3. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #3
    Thanks sadcox,

    I've been coding it in PHP for the mysql database and I do have phpmyAdmin so I'll check that out and see if I can get it to work there.

    Is OR definitely the word to use for doing ORs?
     
    Weirfire, Jun 7, 2005 IP
  4. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #4
    Looks like it could be some other syntax error that I've made because my query that I had worked properly.

    Thanks for your help though sadcox. :)
     
    Weirfire, Jun 7, 2005 IP
  5. sadcox66

    sadcox66 Spirit Walker

    Messages:
    496
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Good luck with it. If you post the error message I may be able to give more information.
    I am guessing at this point the error message is probably from PHP.
    +By the way most server administrators (cPanel/Plesk) already have phpMyAdmin already installed if you need to debug further.
     
    sadcox66, Jun 9, 2005 IP
  6. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #6
    It was a human error that I made for the OR not to work. I had actually written the right query but forgot to display the results correctly for the query I had scripted.

    Sometimes it just takes a wee while to notice the errors though :)
     
    Weirfire, Jun 9, 2005 IP