Help with php query

Discussion in 'MySQL' started by piniyini, May 30, 2006.

  1. #1
    How do I do this with one query, tried a few things and cant get it to work ...

    SELECT *
    FROM `table`
    WHERE (
    `cat1` = '1'
    OR `cat2` = '1'
    OR `cat3` = '1'
    OR `cat1` = '9'
    OR `cat2` = '9'
    OR `cat3` = '9'
    )
    ORDER BY `id` DESC
    LIMIT 30 , 30
    Code (markup):
    I know its something to do with the WHERE clause.
     
    piniyini, May 30, 2006 IP
  2. woodside

    woodside Peon

    Messages:
    182
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are you getting a mysql error or a php error? Or are you just not getting back what you think you should?
     
    woodside, May 30, 2006 IP
  3. sketch

    sketch Well-Known Member

    Messages:
    898
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    148
    #3
    I don't think you need the parentheses () . Other than that the query looks fine to me too.
     
    sketch, Jun 5, 2006 IP
  4. piniyini

    piniyini Well-Known Member

    Messages:
    514
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    #4
    Thanks guys, I was being an idiot and didn't realise a stupid mistake I was making :eek:
     
    piniyini, Jun 6, 2006 IP
  5. sketch

    sketch Well-Known Member

    Messages:
    898
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    148
    #5
    You should share your stupid mistake so we know not to make it as well ;) Learn from others' mistakes!
     
    sketch, Jun 8, 2006 IP