Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这样的MySQL 数据库
MySQL
id employee_id salary 1 1 10000 2 2 20000 3 3 10000 4 4 40000 5 5 30000
我想选择maximum two salary by using LIMIT。那么如何选择呢?
maximum two salary by using LIMIT
只需按薪水的降序对结果进行排序,并根据需要限制结果集:
SELECT * FROM mytable ORDER BY salary DESC LIMIT 2
在sqlfiddle上查看。
SELECT employee_id, salary From employee order by salary desc limit 2 ;