不行,not exists的前面要加字段名字,不然会出错。
select a.name,a.age,b.detail,b.code from zlb a,xxb b where a.serv_id=b.xh and b.code not exists(select b.code from zlb a,xxb b where a.serv_id=b.xh and b.code  like '%12%)

解决方案 »

  1.   

    select a.name,a.age,b.detail from zlb a,xxb b where a.serv_id=b.xh and not like '%12%'
      

  2.   

    select a.name,a.age,b.detail from zlb a,xxb b where a.serv_id=b.xh and b.code not like '%12%'
      

  3.   

    to MIS_ECSM(小火柴) :
    我知道用你那方法表达能达到那效果,关键是我用not exists难道就不能达到同样效果吗?
    用:select a.name,a.age,b.detail from zlb a,xxb b where a.serv_id=b.xh and not exists(select b.name from zlb a,xxb b where a.serv_id=b.xh and b.code  like '%12%)

    select a.name,a.age,b.detail from zlb a,xxb b where a.serv_id=b.xh and b.code not like '%12%'得到的结果不一样,怪哦!
      

  4.   

    如果有b.code  like '%12%' ,
    那not exists(select b.name from zlb a,xxb b where a.serv_id=b.xh and b.code  like '%12%')
    就为假,整个where就为假,查不出记录的
      

  5.   

    那exists到底是怎么用的,谁能说个经典的例子?
      

  6.   


    select a.name, a.age, b.detail
      from zlb a, xxb b
     where a.serv_id = b.xh
      and b.code not like '%12%'