各位:     请问如下的SQL能否不使用declare语句,直接使用SQL查询出需要的内容来呀?请高手指教一下,谢谢.
declare @aaa  nvarchar(100)
declare @bbb nvarchar(100)
select @aaa = T0.ShortName,@bbb= T0.IntrnMatch from JDT1 T0 WHERE  T0.BaseRef = '1320080022'
select  T0.TransId, T0.IntrnMatch, T0.BaseRef from JDT1 T0  where (T0.ShortName = @aaa and  T0.IntrnMatch = @bbb)

解决方案 »

  1.   

    select T0.TransId, T0.IntrnMatch, T0.BaseRef from JDT1 T0 ,
    (select ShortName , IntrnMatch from JDT1 T0 WHERE T0.BaseRef = '1320080022' ) T1
    where T0.ShortName = T1.ShortName and T0.IntrnMatch = T1.IntrnMatch  
      

  2.   

    我晕哦,你直接这样即可.select TransId, IntrnMatch, BaseRef from JDT1 where BaseRef = '1320080022'