In my MySQL DB I've got one table storing date periods. Each period row has PSTART and PEND columns defining period start and period end dates. How to create a query which will check if one particular date is within any of these periods or not? Number of periods in not fixed!
Asked
Active
Viewed 115 times
2 Answers
0
Based on your question so far, this should give you all rows where date is between PSTART
and PEND
- you can modify depending on your requirements for inclusivity/exclusivity:
SELECT * FROM table WHERE date>=PSTART AND date<=PEND

amaidment
- 6,942
- 5
- 52
- 88
-
-
@sbrbot - First, if you look at the timestamps, I posted my answer before Aknosis' - so it would be incorrect to describe his as 'before' mine. Second, they are not the same, since my answer allows you to control inclusivity/exclusivity of start and end dates. – amaidment Dec 03 '12 at 10:57