Excluding a row

Discussion in 'PHP' started by Al Capone, Feb 12, 2006.

  1. #1
    First off hi everyone :)
    Ok, right now I use this script to retrieve top 3 "Old School Games" which is in the "category" row in mySQL

    Now I want to retrieve top 3 games from every category except "Old School Games"

    I tried this

    But it didn't work. The red area is what I am having problems with. Does anyone know how I would accomplish gathering the top 3 games from all the categories except 'Old School Games'? Hopefully I am not to confusing.

    Thanks in advance for any help :)
     
    Al Capone, Feb 12, 2006 IP
  2. Bob_

    Bob_ Peon

    Messages:
    31
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Don't know MySQL that well, but doesn't it support the != operator?

    $sql2 = "SELECT * FROM games Where category!='Old School Games' ORDER BY played DESC LIMIT 0,3";
    Code (markup):
     
    Bob_, Feb 12, 2006 IP
  3. yo-yo

    yo-yo Well-Known Member

    Messages:
    4,619
    Likes Received:
    206
    Best Answers:
    0
    Trophy Points:
    185
    #3
    Bob has it right, (at least in most current versions of mysql) this will work:

    Where category!='Old School Games'

    The code != is telling mysql "DOES NOT EQUAL"
     
    yo-yo, Feb 12, 2006 IP
  4. arnek

    arnek Active Member

    Messages:
    134
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    If i'm not mistaken you can also use

    which also does the same.
     
    arnek, Feb 12, 2006 IP
  5. Al Capone

    Al Capone Well-Known Member

    Messages:
    784
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    140
    #5
    thanks guy :)
     
    Al Capone, Feb 12, 2006 IP