条件查询语句怎么用?

ylh7608 2006-04-18 04:07:20
列中有数据INT类型,1 4 5 7 8 9怎样自动查出2 3 6
...全文
149 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
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 你的表)

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧