首页 > 解决方案 > How to correct this if exists query?

问题描述

Do you know why this piece of code returns syntax error? A subquery executes properly.

 if exists (
 select ad_ulica from #adresy_sprawdzenie where DN=1 and RN=1 and  
 ad_ulica=(select ad_ulica from #adresy_sprawdzenie where DN=1 and    
 RN=2)        
 )

标签: tsql

解决方案


发现一个问题,并在下面修复它:

if exists (
 select ad_ulica from #adresy_sprawdzenie where DN=1 and RN=1 and  
 ad_ulica in (select ad_ulica from #adresy_sprawdzenie where DN=1 and    
 RN=2)        
 )
     begin

     -- tsql here

     end
 else
     begin

     -- tsql here

     end

代替...and ad_ulica =(select ad_ulica from #adresy_sprawdzenie where DN=1 and RN=2)

我用 替换了等号in

让我知道它是否有效。


推荐阅读