共通データベースページングコード
1445 ワード
MySQL
Oracle
HSQLDB
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
Oracle
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
HSQLDB
select * from Cat limit ? ?
select * from Cat limit 20000 100
Cat 20000 100 , 20000 20099
select * from Cat top ?
select * from Cat top 100
Cat 1 100
SQL Server
select top ? * from Cat order by newid()
select top 100 * from Cat order by newid()
Cat 100