Hi ,
I have a query select * from login order by UserID desc limit 2; But it shows that Incorrect syntax near 'limit'.
Please help me.
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Abhay ShankerRank #375 · 6.7K reputationPosted Mar 26, 2014, 9:55 PM EDT
So you need to modify your query as below
select TOP 2 * from login order by UserID desc
Munesh SharmaRank #174 · 13.9K reputationPosted Mar 26, 2014, 9:30 PM EDT
SELECT TOP number|percent column_name(s)
FROM table_name;
mysql support "Limit" keyword
SELECT column_name(s)
FROM table_name
LIMIT number;
you use this query and run it
select TOP 2 * from login order by UserID desc