获取最高薪水的前5名记录

Aja*_*jay 2 mysql

我有3列id,usrname和salary.我想找到最多5个记录的工资.我将如何在mysql中编写查询?

Mar*_*ers 7

In MySQL you can use ORDER BY to sort the rows in descending order and use LIMIT to return only the top 5 rows:

SELECT id, usrname, salary
FROM yourtable
ORDER BY salary DESC
LIMIT 5
Run Code Online (Sandbox Code Playgroud)