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 8341 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

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 decode a base64 string in C#?

Here's a sample code snippet demonstrating how you can easily decode a base64 encoded string in C#. ...

How to disable editing of items in a combo box in c#?

When working in Win forms using C# and especially when you use the combo box , you would have notice...