sql except 用法,找两个表中非共同拥有的

;with tt as (select a.id as id from [dbo].[1234] a where a.id not in (select a.ProtocolID from ProtocolInfo a where InfoUpdateTime>'2015-06-19 14:49:00.307'))


--select 25735+99352
--25735
select cc.DebetType,cc.UpdateTime,cc.InfoAddTime,* from ProtocolInfo cc where ProtocolID in (
select aa.ProtocolID from ProtocolInfo aa where aa.InfoUpdateTime<='2015-06-19 14:49:00.307'
except
select tt.id from tt
)

 

 

EXCEPT是指在第一个集合中存在,但是不存在于第二个集合中的数据。

INTERSECT是指在两个集合中都存在的数据。

posted @ 2015-06-24 17:44  秋香姑娘请你不要紧张  阅读(605)  评论(0编辑  收藏  举报