SQL语句取出一个表格中第21到第25条记录怎么写?

如题所述

mysql的话
select * from table limit 21,5
limit 起始值 , 偏移量
select * from table where id>=21 and id =< 25 这种方法是不行的。

如果是 access或者SQLSERVER的话就只有通过程序来进行操作读取了。
温馨提示:内容为网友见解,仅供参考
第1个回答  2011-06-13
mysql的话
select * from table limit 21,5
limit 起始值 , 偏移量本回答被网友采纳
第2个回答  2011-06-13
sqlserver:
select top25 * from 表
where not exists (select top20 * from 表)
oracle
select * from 表 where rowid between 21 and 25
rowid为系统隐藏字段
第3个回答  2011-06-15
--方法一
select identity(int) id0,* into #temp from tablename order by username
select * from #temp where id0 > =21 and id0 <= 25
----方法二---------------------------------------
with tb as
(select id=row_number() over(order by username),* from b where id between 21 and 25)
select * from tb
----三------------------------------------------------------------------------------

select top 21 * from (select top 25 * from table order by id asc) table_别名 order by id desc
第4个回答  2011-06-13
select * from table where id>=21 and id =< 25
相似回答