Reputation: 23
Consider the following scenario
I want to select all columns from table A where
2016-01-01
and now()
and clubid=2
timesbilled>0
and clubid=2
I am trying the following (The sample is big enough to have the sample)
Select *
From Table A
Where
SubscribeDate between '2016-01-01' and now()
and clubid=2
OR
timesbilled>0
Will the query meet my requirement?
Upvotes: 0
Views: 44
Reputation: 520908
I would phrase your query as:
SELECT *
FROM TableA
WHERE (SubscribeDate BETWEEN '2016-01-01' AND NOW() OR timesbilled > 0) AND
clubid = 2
Both of your listed conditions require a clubid
of 2
. The other requirement is that the date condition or billing condition be true.
Upvotes: 2
Reputation: 738
Try the following
Select *
From Table A
Where
(SubscribeDate between '2016-01-01' and now()
and clubid=2)
OR
(timesbilled>0 and clubid=2);
Upvotes: 1