想实现满足 aaa 与 bbb 表 的条件才执行insert into 语句,不知道该怎么写?if exists (select * from aaa where strID = 1) and (select * from bbb where strID = 1) 
  begin
       insert into ......
   end

解决方案 »

  1.   

    if exists (select * from aaa where strID = 1) and exists (select * from bbb where strID = 1)  
      begin
      insert into ......
      end
      

  2.   

    if exists (select * from aaa where strID = 1) and exists(select * from bbb where strID = 1) 
      

  3.   

    if exists (select * from aaa  INNER JOIN bbb ON aaa.strID=bbb.strID where aaa.strID = 1)
      begin
      insert into ......
      end