求教:用外关联查询
在table1 中的name字段存了两个名字:dong,wang
在table2中的name2字段存了一个名字:dong要求用外关联查找出没有在table2.name2中出现的那个名字wang请指教谢谢

解决方案 »

  1.   

    select s.name1 from @table2 as t
    left join
    @table1 as s
    on t.name2 <> s.name1
      

  2.   

    select * from table1 where name not in(select name from table2)
    或者
    select * from table1 where not exists(select * from table2 where table1.name=table2.name)
      

  3.   

    可以帮我写一个用类似left join外联实现功能的代码么
      

  4.   

    declare @a table (name1 varchar(10))
    insert into @a select 'wang'
    union all select 'dong'
    select * from @adeclare @b table (name2 varchar(10))
    insert into @b select 'dong'
    select * from @bselect name1,name2 from @a left join @b on name1=name2 where name2 is null