How to select Top 10 records in MySQL?
MySQL does not have the TOP keyword of SQL Server. Use LIMIT with ORDER BY.
SELECT name, marks
FROM students
ORDER BY marks DESC
LIMIT 10;
This returns the 10 students with the highest marks. With only 6 rows in the table, it returns all of them, from the highest marks to the lowest. Without ORDER BY the rows that you get are not guaranteed. See MySQL LIMIT.
Learn more about the similar topics:
| Tutorials |
|---|
| MySQL SELECT Statement |
| MySQL WHERE Clause |
| MySQL AND, OR and NOT |
| MySQL ORDER BY |
| MySQL LIMIT |
| MySQL DISTINCT |
| MySQL LIKE and Wildcards |