日期:2014-05-18 浏览次数:20537 次
--uid和IP和numiid有一项不相同的 select * from adshowlog2 as a where not exists(select 1 from dshowlog where uid=a.uid and ip=a.ip and numiid=a.numiid) --uid存在,IP和numiid有一项不相同 select * from adshowlog2 as a where not exists(select 1 from dshowlog where uid=a.uid and ip=a.ip and numiid=a.numiid) and exists(select 1 from dshowlog where uid=a.uid)
------解决方案--------------------
select a2.uip from adshowlog a, adshowlog2 a2 where a.ip <> a2.ip and a.numidd <> a2.numidd
------解决方案--------------------
这样就行了
select * from adshowlog2 as a where not exists(select 1 from dshowlog where ip=a.ip and numiid=a.numiid)
------解决方案--------------------
要查询不存在,一想就是not exists
大版的正解
------解决方案--------------------
select * from adshowlog2 as a where not exists(select 1 from dshowlog where ip=a.ip and numiid=a.numiid)
------解决方案--------------------
使用相关子查询和not exists
------解决方案--------------------
exists的查询过程 ,只要有一条查询结果,则终止该次查询,执行下一次查询
------解决方案--------------------
用左连接,去掉null