select DecNo from A
怎么把DecNo 的值作为字段在B表中取值呢,求一条语句,谢谢各位
8 个解决方案
#1
取值是什么意思?
#2
declare @a varchar(1000)
set @a='select '
select @a=@a+DecNo from A
select @a=left(@a,len(@a)-1)
exec(@a+' from B')
set @a='select '
select @a=@a+DecNo from A
select @a=left(@a,len(@a)-1)
exec(@a+' from B')
#3
select b.* ,c.DecNo from b , (select DecNo from A ) c
---这个意思麽?
---这个意思麽?
#4
比如select DecNo from A 出来的是
1 A1
2 B1
3 C1
那么select A1,B1,C1 from B就行了
就是select DecNo from A 和 select A1,B1,C1 from B 怎么关联到一起
1 A1
2 B1
3 C1
那么select A1,B1,C1 from B就行了
就是select DecNo from A 和 select A1,B1,C1 from B 怎么关联到一起
#5
declare @a varchar(1000)
select @a=@a+','+DecNo from A
select @a=stuff(@a,1,1,'')
exec('select '@a+' from B')
#6
能不能用一句就搞定呢
#7
create table a(id int,DecNo varchar(10))
insert a
select 1, 'A1' union all
select 2, 'B1' union all
select 3, 'C1'
declare @a varchar(1000)
select @a=''
select @a=@a+','+DecNo from A
select @a=stuff(@a,1,1,'')
select 'select '+@a+' from B'
exec('select '+@a+' from B')
insert a
select 1, 'A1' union all
select 2, 'B1' union all
select 3, 'C1'
declare @a varchar(1000)
select @a=''
select @a=@a+','+DecNo from A
select @a=stuff(@a,1,1,'')
select 'select '+@a+' from B'
exec('select '+@a+' from B')
#8
一句话搞不定吧
#1
取值是什么意思?
#2
declare @a varchar(1000)
set @a='select '
select @a=@a+DecNo from A
select @a=left(@a,len(@a)-1)
exec(@a+' from B')
set @a='select '
select @a=@a+DecNo from A
select @a=left(@a,len(@a)-1)
exec(@a+' from B')
#3
select b.* ,c.DecNo from b , (select DecNo from A ) c
---这个意思麽?
---这个意思麽?
#4
比如select DecNo from A 出来的是
1 A1
2 B1
3 C1
那么select A1,B1,C1 from B就行了
就是select DecNo from A 和 select A1,B1,C1 from B 怎么关联到一起
1 A1
2 B1
3 C1
那么select A1,B1,C1 from B就行了
就是select DecNo from A 和 select A1,B1,C1 from B 怎么关联到一起
#5
declare @a varchar(1000)
select @a=@a+','+DecNo from A
select @a=stuff(@a,1,1,'')
exec('select '@a+' from B')
#6
能不能用一句就搞定呢
#7
create table a(id int,DecNo varchar(10))
insert a
select 1, 'A1' union all
select 2, 'B1' union all
select 3, 'C1'
declare @a varchar(1000)
select @a=''
select @a=@a+','+DecNo from A
select @a=stuff(@a,1,1,'')
select 'select '+@a+' from B'
exec('select '+@a+' from B')
insert a
select 1, 'A1' union all
select 2, 'B1' union all
select 3, 'C1'
declare @a varchar(1000)
select @a=''
select @a=@a+','+DecNo from A
select @a=stuff(@a,1,1,'')
select 'select '+@a+' from B'
exec('select '+@a+' from B')
#8
一句话搞不定吧