How to select Top 5 records from a table in MySQL?

Published on May 22, 2013 by abundantcode

Filed under MySQL

Last modified May 22, 2013

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 4527 times

Assume that you have a scenario where you need to retrieve the only the top 5 rows who has the maximum salary from the Employees table.

The column name is salary and the table name is Employees.

How to select Top 5 records from a table in MySQL?

To retrieve the Top 5 employees with maximum salary, order the records by descending order by salary and use the LIMIT keyword to retrieve the top 5 records as shown below.

SELECT salary FROM Employees ORDER BY salary DESC LIMIT 5
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Comment


You might be Interested in these Posts

How to Display list of databases on a MySQL?

If you want to display the list of databases in a MySQL server, you can use the command 'show databa...

How to return Http Status Code from ASP.NET Web API Controller ?

There are times when you might want to return the Http Status code from an action method of a ASP.NE...

How to get the Relative Server Path in ASP.NET Web API ?

In ASP.NET MVC , we can use the Server.MapPath or Request.MapPath to get the relative path of the se...