oracle 的分页与 mySQL'的分页转化
oracle 分页: 关键字ROWNUM
SELECT
EMPNO,
ENAME,
JOB,
MGR,
HIREDATE,
SAL,
COMM,
DEPTNO
FROM
(
SELECT A.*, ROWNUM RN
FROM (SELECT EMPNO,
ENAME,
JOB,
MGR,
TO_CHAR(HIREDATE,'yyyy-MM-dd') HIREDATE,
SAL,
COMM,
DEPTNO
FROM
EMP
ORDER BY EMPNO) A
WHERE ROWNUM <=
<if test="INCREMENT != null" >
${INCREMENT}
</if>
)
WHERE RN >
<if test="FROM != null" >
${FROM}
</if>
MySQL 的分页:关键字LIMIT
SELECT
EMPNO,ENAME, JOB, MGR, DATE_FORMAT(HIREDATE,'%Y-%c-%d') HIREDATE,SAL,COMM,DEPTNO
FROM
(
SELECT A.*
FROM (SELECT * FROM EMP_JBXX_ZS ORDER BY EMPNO ASC) A
) B
LIMIT
<if test="FROM != null" >
${FROM}
</if>
,
<if test="INCREMENT != null" >
${INCREMENT}
</if>
注意:oracle中RUMNUM 是特有的,注意大小的顺序,
mySQL 问题比较多,注意嵌套式查询时,要注意使用 指代名,最后一个B 必须有