查询N-M条记录。
select IDENTITY(int,1,1) as iid,* into #temptable from yourtable
select top M * from #temptable where iid>=NOR:select top M * from yourTable where id not in(select top N-1 id from table)
ID为表具有唯一值的任何字段
解决方案 »
- 求助
- 如何减轻数据库压力,减少CPU使用率,在线等
- 如何处理某些表完成了新数据导入操作后,自动遴选数据进行组合、计算后插入另外表?
- 请问No rows affected是什么异常
- 请教邹建:怎么执行动态sql ???已经被折磨了数天,帮帮我.....
- 为什么有时会插入成功,有时插入不成功
- 请问 create/drop table 是否记录日志
- ====SQL 面试题 [高手请进]~~=====
- 使用linkedserver访问有密码的ACCESS数据库的问题
- 每次从库中取一条记录,要求最近的20条不能有相同记录,谁有些简单方法.
- 有新闻表 栏目表,现在查询新闻标题,要获得每个栏目里跟关键词相关的新闻数量???
- SQL语句!
哦,还有个问题要澄清,主键为一个字符串。
insert @ values ('A',5)
insert @ values ('be', 5)
insert @ values ('cs', 5)
insert @ values ('y', 6)
insert @ values ('e', 6)
insert @ values ('f', 6)
insert @ values ('g', 7)
insert @ values ('h', 7)
insert @ values ('i', 7)--以下这句相当于"蚂蚁"的
--select top M * from yourTable where id not in(select top N-1 id from table)
Select top 2 * from @ where col_no not in (select top 3 col_no From @)
其中{}中的需要你修改。
GZ ing
select * from #temp where ID_Num>10 and ID_Num<=20
从publish 表中取出第 n 条到第 m 条的记录:
SELECT TOP m-n+1 *
FROM publish
WHERE (id NOT IN
(SELECT TOP n-1 id
FROM publish))id 为publish 表的关键字