tclogo



HotelsCombined.com

Pages

Archives

Categories


Recent Postings

Recent Comments

Feeds

RSS2 feed

Links

Most Popular Posts

MySQL equivalent of Top

Thursday, 23rd March 2006 6:08am
How many times have I have tried to use a SQL server command in MySql and it has failed? Quite a few. This time the command involved was 'top'. Something you would normally use in SQL server like 'select top 8' doesn't work in MySQL but you should use the equivalent of 'top' which is 'limit'.


So while for SQL server you would say:


select top 8 * from products


the equivalent of this in MySQL would be:


select * from products limit 8


Please note that limit can have two arguments, the first one indicates the first row to return in the returned result set and the other argument the maximum number of rows to return but I will not discuss that in this posting.

Post a comment:

 

(required)

(required, but not published)

(optional)





Notify me of follow-up comments via e-mail