常用資料庫分頁語句

2021-08-29 23:56:33 字數 1145 閱讀 4266

select * from cat limit ?,?

select * from cat limit 20000,100

從cat表中第20000條開始取出100條記錄,即記錄號為20000到20099的記錄

select * from cat limit ?

select * from cat limit 100

從cat表中取出記錄號為1到100的記錄

select * from cat order by rand() limit ?

select * from cat order by rand() limit 100

從cat表中隨機取出100條記錄

select * from (select *, rownum rownum_ from cat where rownum <= ?) where rownum_ > ?

select * from (select *, rownum rownum_ from cat where rownum <= 20099) where rownum_ > 19999

從cat表中第20000條開始取出100條記錄,即記錄號為20000到20099的記錄

select * from cat where rownum <= ?

select * from cat where rownum <= 100

從cat表中取出記錄號為1到100的記錄

select * from (select * from cat order by dbms_random.value) where rownum < ?

select * from (select * from cat order by dbms_random.value) where rownum < 100

從cat表中隨機取出100條記錄

select top ? * from cat order by newid()

select top 100 * from cat order by newid()

從cat表中隨機取出100條記錄

常用資料庫分頁語句及資料庫程式設計

取出sql表中第31到40的記錄 以自動增長id為主鍵 sql server 方案1 select top 10 from t where id not in select top 30 id from t order by id orde by id sql server 方案2 select t...

資料庫分頁語句

1 mysql select from tb user order by id asc limit 10 offset 10 size small color blue limit指定每頁大小,offset指定偏移量,在程式 中可以寫成這樣 select from tb user order by ...

資料庫分頁語句

取出sql表中第31到40的記錄 以自動增長id為主鍵 sql server方案1 select top 10 from t where id not in select top 30 id from t order by id orde by id sql server方案2 select top...