#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    21
    Rep Power
    0

    Using TOP Clause in MYSQL


    Hi! I want to use TOP Clause in MySQL but i'm unable to do it. The SQL Statement is as below:

    SELECT TOP * FROM Persons

    It display the error saying:

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2 * from persons LIMIT 0, 30' at line 1

    MySQL version is 5.5.27. Please help me to penetrate the above query in MySQL?
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,280
    Rep Power
    4279
    Originally Posted by RajaGa
    The SQL Statement is as below:

    SELECT TOP * FROM Persons
    that is ~not~ the sql statement

    how do i know this? because the portion of the actual sql statement included in the error message looks different

    please try again

    p.s. here's a hint -- TOP is not supported in mysql
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,788
    Rep Power
    349
    Originally Posted by RajaGa
    check the manual that corresponds to your MySQL server version for the right syntax to use
    What did you find out when you followed that excellent advice?
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
    http://forums.devshed.com/misc.php?do=bbcode#code

    Tips on how to ask better questions:
    http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    21
    Rep Power
    0
    Thanks, for you advice r937.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    21
    Rep Power
    0
    Thanks, for your advice shammat.

IMN logo majestic logo threadwatch logo seochat tools logo