考虑以下情况
我想从表A中选择所有列
2016-01-01
和now()
以及clubid=2
timesbilled>0
和clubid=2
我正在尝试以下(样本足够大以获得样本)
Select *
From Table A
Where
SubscribeDate between '2016-01-01' and now()
and clubid=2
OR
timesbilled>0
查询是否符合我的要求?
答案 0 :(得分:2)
我会将您的查询说成:
SELECT *
FROM TableA
WHERE (SubscribeDate BETWEEN '2016-01-01' AND NOW() OR timesbilled > 0) AND
clubid = 2
您列出的所有条件都需要clubid
2
。另一个要求是日期条件或结算条件为真。
答案 1 :(得分:1)
尝试以下
Select *
From Table A
Where
(SubscribeDate between '2016-01-01' and now()
and clubid=2)
OR
(timesbilled>0 and clubid=2);