insert into A(a,b,c)
select * from (
select e,f,g from B where e!=15 
union all 
select C.e,C.f,C.g from C) t
where exists(select e,f,g from B where e!=15 )

解决方案 »

  1.   

    IF EXISTS(SELECT 1 FROM TB WHERE  e!=15 )
       SELECT E,F,G FROM B WHERE E!=15
       UNION ALL
       SELECT E,F,G FROM C
      

  2.   

    if exists(select 1 from b where e!=15)
        insert into A select e,f,g from B where e!=15 union all select C.e,C.f,C.g from C 
      

  3.   

    insert into A 
    select e,f,g from B where e!=15
    union all 
    select C.e,C.f,C.g from C where exists(select e,f,g from B where e!=15)