select id,name from s_emp where rownum <= 20 and rownum >11; // 錯!
1. rownum 並不是 DB 中本身有的一個字段,因此不能寫 > ;
2. rownum 是動態編號的,先將數據拿出來再編號,拿出來一個編一個號 ;
如:<= 2,拿出來一個,編號1,要;
拿出來一個,編號2,要;
拿出來一個,編號3,不要了;
又如:> 6,拿出來一個,編號1,1<6,不要;因此永遠就取不出來數據。
3. 若想 <= 20 且 >= 11,
則:select id,name from (select id,name,rownum num from s_emp
where rownum <= 20 ) where num >11
4. MySql 中,分頁有:select id from s_emp limit 10,20;