条件查询语句怎么用?

ylh7608 2006-04-18 04:07:20
列中有数据INT类型,1 4 5 7 8 9怎样自动查出2 3 6
...全文
113 4 点赞 打赏 收藏 举报
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
itblog 2006-04-18
--测试数据
create table T( id int)
insert into T
select 1 union
select 4 union
select 6 union
select 8 union
select 10 union
select 11
--查询语句
select id-1 as 缺号 from t a where id>1 and not exists(select * from t where id=a.id-1)
  • 打赏
  • 举报
回复
刘建 2006-04-18
create table T
( id int)
insert into T
select 1 union
select 4 union
select 6 union
select 8 union
select 10 union
select 11

declare @max int

select @max =max(id) from T

set rowcount @max
select identity(int,1,1) as num into # from sysobjects,syscolumns
set rowcount 0


select num from # where num not in (select id from T)

drop table #,T

测试了.你试试
  • 打赏
  • 举报
回复
jiaojian843 2006-04-18
where id in(2,3,6)
  • 打赏
  • 举报
回复
xiaoku 2006-04-18
select id from
(
select 1 as id
Union all select 2 Union all select 3
Union all select 4 Union all select 5
Union all select 6 Union all select 7
Union all select 8 Union all select 9
) aa
where id not in (select 你的列 from 你的表)
  • 打赏
  • 举报
回复
相关推荐
发帖
MS-SQL Server
加入

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2006-04-18 04:07
社区公告
暂无公告