日期:2014-05-17  浏览次数:20554 次

Sql中怎样跳跃读取行
表A:
ID         Text
1          8888
2          2222
3          11111
4          098023
5          929829842
6          9908082083
7          8777923
8          89789
9          897982932
........

现在我想得到 id=1 id=4 id=7 ....
得到每个ID+3的数据。。请指教

SQL

------解决方案--------------------
if object_id('[TB]') is not null drop table [TB]
go
create table [TB] (ID int,Text nvarchar(20))
insert into [TB]
select 1,'8888' union all
select 2,'2222' union all
select 3,'11111' union all
select 4,'098023' union all
select 5,'929829842' union all
select 6,'9908082083' union all
select 7,'8777923' union all
select 8,'89789' union all
select 9,'897982932'

select * from [TB]

SELECT * FROM TB WHERE id%3=1

/*
ID Text
1 8888
4 098023
7 8777923*/