表A:
  编号   姓名
  001    张三
  002    李四表B:
  编号   工龄
  003    2
  001    3现在要查询表B中有哪些编号表A中没有的.

解决方案 »

  1.   

    select 编号
    from B where B.编号 not in (Select 编号 from A)
      

  2.   

    select 编号
    from B where not exists (Select 1 from A where A.编号=B.编号)
      

  3.   

    select B.编号
    from B left join A on A.编号=B.编号
    where A.编号 is null
      

  4.   

    SELECT * FROM B T WHERE NOT EXISTS(SELECT 1 FROM A WHERE A.编号=T.编号)
      

  5.   

    SELECT * FROM B T WHERE 编号 NOT IN (SELECT 编号 FROM A )
    编号唯一
      

  6.   

    select 编号 from B except select 编号 from A