Select @A=b.A, @B=b.B
from 表C a Join 
     表Y b on a.A=b.A
where a.D=@D

解决方案 »

  1.   

    select @A=a.A ,@B=a.B 
    from 表Y a,表c b 
    where b.d=@d and a.a=b.a
      

  2.   

    select @A=A ,@B=B 
    from 表Y
    where @A in ( select A
         from 表C
         where 表C.A=@D)
      

  3.   

    TO:lsxaa(小李铅笔刀
    必须是当变量@D=(旺财)时 才行
      

  4.   

    TO;yesterday2000(一笑而过) 写的表名称好象不对
      

  5.   

    create table c (a char (2),d char (10))
    create table y (a char (2),b char (2))insert into c 
    select '01','小强'
    union
    select '02','旺财'insert into y
    select '01','19'
    union
    select '02','20'
    union
    select '03','21'
    union
    select '04','22'
    declare @a char (10),@b char (10),@d  char (10)
    set @d='旺财'
    select @A=a.A ,@B=a.B 
    from Y a,c b 
    where b.d=@d and a.a=b.a
    select @a,@b,@d01    19    小强
      

  6.   

    变量@D是你自己赋值的,想赋什么值都行啊      select @A=A ,@B=B 
              from 表Y
              where @A in ( select A
                   from 表C
                   where rtrim(表C.A)=@D)   --去尾空格
      

  7.   

    create table c (a char (2),d char (10))
    create table y (a char (2),b char (2))insert into c 
    select '01','小强'
    union
    select '02','旺财'insert into y
    select '01','19'
    union
    select '02','20'
    union
    select '03','21'
    union
    select '04','22'
    declare @a char (10),@b char (10),@d  char (10)
    set @d='小强'
    select @A=a.A ,@B=a.B 
    from Y a,c b 
    where b.d=@d and a.a=b.a
    select @a,@b,@d01    19    小强