• 全部
  • 基础类
  • 应用实例
  • 新技术前沿

求一个select语句,刚才没把问题描述清楚

tianhuo_soft 2008-04-07 01:20:54
create table #tb (vNo varchar(15))
insert into #tb
select '2006206110'
union all
select '2006216700'
union all
select '2006236570'
union all
select '2006237470'
union all
select '2006007030'
union all
select '2006069140'

select * from #tb


当我想查询'2006007030' '2006069140' '20061010888'
只返回'20061010888',因为我的表里面没有'20061010888'



...全文
76 点赞 收藏 9
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
-狙击手- 2008-04-08
declare @sql varchar(200)
set @sql='2006007030,2006069140,20061010888'
select @sql=replace(','+@sql+',',','+vno+',','') from #tb
select replace(@sql,',','')



顶这个
回复
JL99000 2008-04-07
我顶你个妃
回复
huangjh_love 2008-04-07
use HC
create table #tb (vNo varchar(15))
insert into #tb
select '2006206110'
union all
select '2006216700'
union all
select '2006236570'
union all
select '2006237470'
union all
select '2006007030'
union all
select '2006069140'

declare @sql varchar(200)
set @sql='2006007030,2006069140,20061010888'
select @sql=replace(','+@sql+',',','+vno+',','') from #tb
select replace(@sql,',','') vNo
drop table #tb

回复
wangxuelid 2008-04-07

/*
20061010888

*/
回复
pt1314917 2008-04-07

create table #tb (vNo varchar(15))
insert into #tb
select '2006206110'
union all
select '2006216700'
union all
select '2006236570'
union all
select '2006237470'
union all
select '2006007030'
union all
select '2006069140'

declare @sql varchar(200)
set @sql='2006007030,2006069140,20061010888'
select @sql=replace(','+@sql+',',','+vno+',','') from #tb
select replace(@sql,',','')

回复
wangxuelid 2008-04-07
create table #tb (vNo varchar(15)) 
insert into #tb
select '2006206110'
union all
select '2006216700'
union all
select '2006236570'
union all
select '2006237470'
union all
select '2006007030'
union all
select '2006069140'

Create table #tab (a varchar(20))
insert into #tab
select '2006007030' union
select '2006069140' union
select '20061010888'

select * from #tab where a not in (select vNo from #tb )
回复
areswang 2008-04-07
create table #tb (vNo varchar(15))
insert into #tb
select '2006206110'
union all
select '2006216700'
union all
select '2006236570'
union all
select '2006237470'
union all
select '2006007030'
union all
select '2006069140'


create procedure test @vNO AS VARCHAR(15) OUTPUT
AS
SELECT TOP 1 @vNO FROM #TB WHERE VNO<>@VNO

EXEC TEST '20061010888'
回复
jinjazz 2008-04-07
create table #tb (vNo varchar(15)) 
insert into #tb
select '2006206110'
union all
select '2006216700'
union all
select '2006236570'
union all
select '2006237470'
union all
select '2006007030'
union all
select '2006069140'
select * from (
select '2006007030' as vno union select '2006069140' union select '20061010888' )a
where vno not in (select vno from #tb )
drop table #tb
回复
viva369 2008-04-07

create table #tb (vNo varchar(15))
insert into #tb
select '2006206110'
union all
select '2006216700'
union all
select '2006236570'
union all
select '2006237470'
union all
select '2006007030'
union all
select '2006069140'

go

select * from
(
select '2006007030' tblColumn
union all
select '2006069140'
union all
select '20061010888'
) as tbl
where not exists(select * from #tb where vNo = tblColumn)

回复
相关推荐
发帖
MS-SQL Server
创建于2007-09-28

3.3w+

社区成员

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