常用数据库 取前几条数据 sql写法


如在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条记录


々上善若水々 2007-12-24 11:20 发表评论

你可能感兴趣的:(oracle,sql,mysql,db2)