oracle和mysql分页之查询语句区别:
分页时根据数据库类型采取不同的SQL分页语句
①MySql数据库,采用limit语句进行分页
SELECT * FROM USER LIMIT M,N;
从M+1条数据开始,查N条数据
具体事例:
SELECT * FROM USER LIMIT 0,4; 查到是第1-4条数据
②Oracle数据库,采用rownum的方式进行分页(查询数据库前4条数据)
1.SELECT * FROM (SELECT TEMP.*, ROWNUM RN FROM (SELECT * FROM USER)TEMPWHERE ROWNUM <= 4)WHERE RN >= 1;
2.SELECT * FROM (SELECT TEMP .*, ROWNUM RN FROM (SELECT * FROM USER)TEMP)WHERE RN BETWEEN 1 AND 4;
指定具体参数可以把ROWNUM一起查出来3.SELECT * FROM(SELECT ROWNUM RN ,ID,NAME,PASSWORD FROM USER WHERE ROWNUM <= 4)TEMPWHERE RN >= 1;