当前位置: 代码迷 >> Sql Server >> 请教SQL SERVER怎么实现多列NOT IN,多谢
  详细解决方案

请教SQL SERVER怎么实现多列NOT IN,多谢

热度:41   发布时间:2016-04-27 12:42:49.0
请问SQL SERVER如何实现多列NOT IN,谢谢
select exhibitionid,exhibitionnamecn,begintime,adddate,country from jdsh_Exhibition 
where ifimport <> 1 and (begintime,endtime,exhibitionnamecn) not in 
(select begintime,endtime,name from jdsh_Exhibition_web) order by exhibitionid desc

这是我的语句,ORACLE里支持多列IN,就可以执行,但是SQL SERVER就不行。请问该如何改,谢谢

------解决方案--------------------
楼主,sql多列not in也是可以的,用列名+列名+列名 这种方式就是可以了。很简单的。
------解决方案--------------------
随便一写,试试:
select a.exhibitionid,a.exhibitionnamecn,a.begintime,a.adddate,a.country 
from jdsh_Exhibition as a
where ifimport <> 1 
and not exists (select top 1 * from jdsh_Exhibition_web as b where a.begintime=b.begintime and a.endtime=b.endtime and a.exhibitionnamecn=b.name)
order by a.exhibitionid desc
------解决方案--------------------
更好的是:
SQL code
select a.exhibitionid,a.exhibitionnamecn,a.begintime,a.adddate,a.country from jdsh_Exhibition as awhere ifimport <> 1 and not exists (select 1 from jdsh_Exhibition_web as b where a.begintime=b.begintime and a.endtime=b.endtime and a.exhibitionnamecn=b.name)order by a.exhibitionid desc
  相关解决方案