标签:limit select 记录 -- rownum desc mysq 数据库 多少
查询员工表中薪水从高到低排序的第5~9条记录
============================================================
SELECT *
FROM (SELECT e.*,rownum rn FROM (SELECT * FROM employee ORDER BY sal DESC) e)
WHERE rn>=5 AND rn<=9;
SELECT *
FROM (SELECT E.*, ROWNUM RN
FROM (SELECT * FROM EMPLOYEE ORDER BY SAL DESC) E WHERE ROWNUM<=9 )
WHERE RN >= 5;
--mysql
SELECT * FROM EMPLOYEE ORDER BY SAL DESC LIMIT 4 , 5
该sql语句的意思是,从第几行开始,然后取多少行,MySQL中第一行的下标是0
标签:limit select 记录 -- rownum desc mysq 数据库 多少
原文地址:http://www.cnblogs.com/984187775blog/p/7254072.html