select a.* from 表1 a,表2 b where a.姓名<>b.姓名

解决方案 »

  1.   

    select * from 表1 where 姓名 not in (select distinct 姓名 from 表2)
      

  2.   

    select * from 表1 where not exists (select 姓名 from 表2 where 表2.姓名=表1.姓名)
      

  3.   

    select *
    from 表1
    where 表1.姓名 not exsist (select distinct 表2.姓名 from 表2)
      

  4.   


    select * from 表1 a
    where not exists(
    select 1 from 表2 where 姓名=a.姓名)
      

  5.   

    发扬拿来主义的精神,投机取巧一下:
    select 姓名 from 表1 a
    where not exists(
    select 1 from 表2 where 姓名=a.姓名)
      

  6.   

    select 姓名 from 库1.dbo.表1 a
    where not exists(
    select 1 from 库2.dbo.表2 where 姓名=a.姓名)^_^!哈哈!
      

  7.   

    在库1里执行
    select a.* from 表1 a,库2.dbo.表2 b where a.姓名<>b.姓名

    select 姓名 from 表1 a
    where not exists(
    select 1 from 库2.dbo.表2 where 姓名=a.姓名)