select * from a where not exists(select 1 from b where 序列号=a.序列号)

解决方案 »

  1.   

    --或者:
    select a.* from a left join b on a.序列号=b.序列号 where b.序列号 is null
      

  2.   

    --测试--测试数据
    create table a(手机品牌 varchar(10),序列号 int,进货日期 char(8))
    insert  a select 'nokia',  1,'99-12-1'
    union all select 'nokia',  2,'99-12-2'
    union all select 'samsung',3,'99-12-3'create table b(序列号 int,销售日期 char(8))
    insert b  select 1,'99-12-23'
    union all select 2,'99-12-24'
    go--查询
    select * from a where not exists(select 1 from b where 序列号=a.序列号)--或者:
    select a.* from a left join b on a.序列号=b.序列号 where b.序列号 is null
    go--删除测试
    drop table a,b/*--测试结果--查询方式1的结果手机品牌       序列号         进货日期     
    ---------- ----------- -------- 
    samsung    3           99-12-3 (所影响的行数为 1 行)--查询方式2的结果手机品牌       序列号         进货日期     
    ---------- ----------- -------- 
    samsung    3           99-12-3 (所影响的行数为 1 行)--*/