oracle分頁寫法
$p = $_GET['p'] ? $_GET['p'] : 1; //頁碼
$offset = 30; //每頁的數目
$star = $offset * $p - $offset; //起始行數
$max = $start + $offset; //需要查出的最大行數, 也可以是$offset*$p
select * from
(select t.*, ROWNUM rn from
(
select
URP_SCHEDULE.*, to_char(URP_SCHEDULE.RES_DATE,'yyyy-mm-dd') AS R_DATE,
URP_DEPT.NAME AS DEPT_NAME,
URP_DOCTOR.NAME AS DOCTOR_NAME
from
URP_SCHEDULE,URP_DEPT,
URP_DOCTOR
WHERE
URP_SCHEDULE.DOCTOR_CODE=URP_DOCTOR.CODE AND
URP_SCHEDULE.DEPT_CODE=URP_DEPT.CODE
order by urp_schedule.res_date desc
)
t where ROWNUM <= $max)
where rn > ".$start;
MYSQL的分頁思想是從某一行開始($start), 顯示多少行($offset);
ORACLE的分頁思想是從某一行開始($start)到某一行之間($max);