不行,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%)
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%)
我知道用你那方法表达能达到那效果,关键是我用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%'得到的结果不一样,怪哦!
那not exists(select b.name from zlb a,xxb b where a.serv_id=b.xh and b.code like '%12%')
就为假,整个where就为假,查不出记录的
select a.name, a.age, b.detail
from zlb a, xxb b
where a.serv_id = b.xh
and b.code not like '%12%'