求一个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'



...全文
113 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
-狙击手- 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)

34,575

社区成员

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

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