Quick SQL question

Discussion in 'MySQL' started by Crazedplanet, Dec 30, 2007.

  1. #1
    Hi guys

    I would be really grateful if somebody could help me as I am kinda stuck on a sql issue, I am trying to select based on having a good rating (which is a category) so all I am looking for is to select based on a rating of 4 or above on a scale of 1-5

    "SELECT * FROM news WHERE 'rating' >=4 ASC LIMIT 10"

    which isnt working plus will this take into account decimals such as a rating of 4.5? I am assuming I am doing it wrong as I am fairly new to SQL. Any help would be much appreciated as cant find anything on the web.
     
    Crazedplanet, Dec 30, 2007 IP
  2. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #2
    Decimals being taken into account will depend on the data type used for the "rating" column.

    Try this
    SELECT *
    FROM news
    WHERE rating >= 4
    ORDER BY rating DESC
    LIMIT 10
    Code (markup):
    If it doesn't work, post the results it gives you, followed by the results you're expecting.
     
    joebert, Dec 30, 2007 IP
  3. Crazedplanet

    Crazedplanet Guest

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    that worked great thank you!!
     
    Crazedplanet, Dec 30, 2007 IP
  4. kendo1979

    kendo1979 Peon

    Messages:
    208
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    just a quick peek, should be "ASC".
     
    kendo1979, Dec 30, 2007 IP