现有两个表有相同字段tel,表里tel有不相同部分。两个表的 tel数据类型均为char类型且都允许置空,用命令select * from A where tel in(select tel from B)有结果,但用select * from A where tel not in(select tel from B)结果总是为空,不知道是什么原因???

解决方案 »

  1.   

    命令select * from A where tel in(select tel from B)有结果,但用select * from A where tel not in(select tel from B)结果总是为空这结果要看你表中的数据
      

  2.   

    谢谢了,怎么贴点数啊,我想多给isnull的多点分数
      

  3.   

    点击本页右上方工具条中的"管理"进入结帖页面.
    ----------------------------------------------------------------------
    使用in(子查询)时要注意在子查询中加上where colx is not null这个条件,例如:
    select tel from B where tel is not null
      

  4.   

    create table aa (id int,cj numeric(10,4))
    insert into aa select 1,100
    insert into aa select 2,20
    insert into aa select 3,89
    insert into aa select 4,90
    insert into aa select null,80create table bb (id int ,kc varchar(20))insert into bb select 1,'sx'
    insert into bb select 2,'yw'
    insert into bb select 2,'sx'
    insert into bb select 1,'yw'
    insert into bb select null,'sx'
    select * from aa a where not exists (select * from bb b where a.id = b.id)
      

  5.   

    如果表字段中出现NULL的时候,用not in 是查不到数据的,必须用更高级的查询 not exists。
    今天跟我们老师学的,不知道这么写对不对。呵呵!在苦难中前进!在艰难中成长!
    学习中!
      

  6.   

    昨天我做了实验:null <> null 的!