--LZ的意思有点模糊! --设存在一表,且有自增列,但自增列不一定连接,求表中第3条记录 --答: Declare @t Table(Id Int,Names Varchar(10)) Insert @t Select 1,'a' Union all Select 2,'b' Union all Select 3,'c' -- Select Top 1 * From (Select Top 3 * From @t) A --3为在表中的位置 Order by 1 Desc
select identity(int,1,1) I,字段 into #tmp from 表名 select * from 表名 where I=位置
Select Top 1 * From table where id not in(Select Top 你所要的位置数 * From table) Order by id
楼主的意思是说要select出一个表的第x行的纪录吧 这个你可以在把此表插入一个有自增列的临时表中或给此表建一个自增列 这样就可以select * from table1 where id=x 不知道理解对楼主的意思没有
--设存在一表,且有自增列,但自增列不一定连接,求表中第3条记录
--答:
Declare @t Table(Id Int,Names Varchar(10))
Insert @t Select 1,'a'
Union all Select 2,'b'
Union all Select 3,'c'
--
Select Top 1 *
From (Select Top 3 * From @t) A --3为在表中的位置
Order by 1 Desc
select * from 表名 where I=位置
From table where id not in(Select Top 你所要的位置数 * From table) Order by id
这个你可以在把此表插入一个有自增列的临时表中或给此表建一个自增列
这样就可以select * from table1 where id=x
不知道理解对楼主的意思没有