Search code examples
mysqlsqlinsertlimit

SQL Select Statement Limit & Desc Order


Just need someone to tell me if this statement has the proper syntax or not; i cannot get it to work properly.

SELECT plantname, orderfreq, totalincome 
FROM plantreview 
WHERE score >='5' 
AND recommended='1' 
ORDER BY score DESC, LIMIT +0, 5

Solution

  • Assuming MySQL, there should not be a , after the ORDER BY or + in the LIMIT. If your column is an integer, you also don't need to encase it in quotes.

    SELECT plantname, orderfreq, totalincome 
    FROM plantreview 
    WHERE score >='5' 
    AND recommended='1' 
    ORDER BY score DESC
    LIMIT 0, 5
    

    See it in action