select * from c
where exists (select 1 from (select * from a union select * from b) d where d.id=c.id)

解决方案 »

  1.   

    c表的name值不是a表的name 就是b表的name
    c表的name在a,b里只有一个
      

  2.   

    select c.id,isnull((select name from a where id.c.id),(select name from b where id.c.id)) from c
      

  3.   

    select c.id,isnull((select name from a where id=c.id),(select name from b where id=c.id)) from c
      

  4.   

    select top 1 * 
    from
         (
           select * from a
           union all
           select * from b
         )t
    where id=@cid
      

  5.   

    select *,
           [aOrbID]=t.id
    from c
    join (
         select * from a
         union all
         select * from b
         )t
    on c.id=t.id