加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 数据库 > MsSql > 正文

tSQL NOT IN查询

发布时间:2020-05-28 17:47:36 所属栏目:MsSql 来源:互联网
导读:我想获取[interaction]表的ID,但这些ID不能等于[EmailOUT]表.我无法编写查询. Select ID from EmailOut where ID NOT IN (select ID from [172.28.101.120].[GenesysIS].dbo.interactions where media_type

我想获取[interaction]表的ID,但这些ID不能等于[EmailOUT]表.我无法编写查询.

Select ID from EmailOut         
where ID NOT IN         
   (select ID from
    [172.28.101.120].[GenesysIS].dbo.interactions 
    where media_type = 'email'
    and type = 'Outbound')

类似的东西.我想在交互表中输出外发电子邮件,但这些电子邮件可能存在于EmailOut表中.我想删除它们.出站电子邮件数约为300,但此查询结果应小于300

解决方法

如果你想获得[interaction]表的ID,你似乎应该反转你的查询:
select ID from
[172.28.101.120].[GenesysIS].dbo.interactions 
where media_type = 'email'
and type = 'Outbound'
AND ID NOT IN (SELECT ID FROM EmailOut)

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读