以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  SQL 语句  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=104868)

--  作者:blackzhu
--  发布时间:2017/8/7 13:31:00
--  SQL 语句
s  ele     ct 客户编号,咨询时间,咨询人员,姓名,联系电话,咨询类别  from 客户咨询 a where not exists(sel    ect 1 from 客户咨询 where 客户编号=a.客户编号 And 咨询类别=\'分诊接待\' And 咨询人员 Is Not NULL and  咨询时间<a.咨询时间)



这条语句我明明查询的是分诊接待的数据,但是就是其他类别的数据也给加载了. 应该怎么改?

--  作者:逛逛
--  发布时间:2017/8/7 14:17:00
--  
你用的不是not exists 吗?
--  作者:有点甜
--  发布时间:2017/8/7 14:23:00
--  

方法一:not exists 改成 exists

 

方法二:或者你可以用 in 或者 not in 的语法。