我想弄清楚,我怎么可以创建查询,显示所有的where子句中的结果,但不包括一个电子邮件地址,在结果输出:如何查询 - 不应该包含
select * from [dbo].[UserDetails] u join [dbo].[Subscriptions] s on u.uID = s.sUID
where s.[sPExpiryDate]>= getdate() or s.[sExpiryDate] >= getdate() or [sTExpiryDate] >= getdate()
and (s.[sB_All] = '1' or s.[sB_All] <> '1') or [sStories_Only] = 1
and u.uEmailAddress not in ('[email protected]')
and s.sPID = 163 order by u.uEmailAddress asc
我想要上面的查询输出所有数据但是免除记录,其中包含电子邮件地址= sample @ .gmail.com
当我执行上述查询时,输出仍然显示一条记录,其中包含以下email =品尝@ .gmail.com。我错过了什么吗?
为参照,这就是我[email protected]记录类似于INT数据集:
email sPExpiryDate sExpiryDate sTExpiryDate
[email protected] NULL 2016-04-11 00:00:00.000 2012-03-03 00:00:00.000
请进一步咨询。谢谢
想想用英语说话。 “我想要火腿,鸡蛋或烤面包。”这是否意味着你想要“火腿和(鸡蛋或烤面包)”或“(火腿和鸡蛋)或烤面包”?参见http://databases.aspfaq.com/general/why-do-i-get-weird-results-when-using-both-and-and-or-in-a-query.html – 2015-03-31 15:54:57
是“(s。 [sB_All] ='1'或s。[sB_All] <>'1')'偷偷写作's。[sB_All]不是NULL'? – HABO 2015-03-31 16:06:10