这是我的SQL语句:
SELECT DISTINCT a.*
FROM OWU_Nomination as a,
Merchants as b WHERE a.CallFlag = 'False'
AND a.nominatedDate < DateAdd(hour, -24, getdate())
AND a.email != (SELECT c.Email from Members as c where c.MemberID = b.MemberID)
这里的问题是a.email !=
之后的子选择返回多个记录。我想看看a.email
是否在从子选择返回的任何电子邮件中,这可能吗?是否有包含功能或类似的东西会这样做?
答案 0 :(得分:2)
根据你的问题,我不确定你是否希望它在集合中或不在集合中。
如果必须在集合中,请使用以下句子:
AND a.email IN (SELECT c.Email from Members as c where c.MemberID = b.MemberID)
否则:
AND a.email NOT IN (SELECT c.Email from Members as c where c.MemberID = b.MemberID)