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


x

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 Send e-mail via SMTP using C# ?

Here's a sample code to send email via SMTP using C#. How to Send e-mail via SMTP using C# ? using...

How can you strip non-ASCII characters from a string in C# ?

Regular expressions is one of the easiest way to strip non-ascii characters from a string in C#. Her...