MSSQL
如在ms sqlserver 用此语句:
select top 2 * from test01 就会只显示前2条记录,
MYSQL
select * from your_table where .... limit 2;
使用limit就可以了.
Oracle的语句:
select * from (select rownum r ,* from test) tt
where tt.r > 50 and tt.r <= 100; (最好用PLSQL游标来解决)
DB2中:
select * from payment fetch first 5 row only --查前5条记录
MySQL
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的记录