0
votes

in my database table contains 4 fields like :

 id  Start_date     End_date     Package
 --  ---------      ----------   --------
 1   2013-10-25     2014-04-30    pack 1
 2   2014-01-02     2014-04-30    Pack 2
 3   2014-05-01     2015-06-30    pack 3
 4   2015-07-01                   pack 4

i want to use date (start = 2014-01-01 and end = 2014-08-13) to check if the date is between any of the dates(Start_date, End_date) in the table. For this case, I want to get pack 1, pack 2 and pack 3. how can I do this?

2
Are you sure that pack 1 need to be fetched?LoïcR

2 Answers

0
votes

Use BETWEEN keyword of mysql

SELECT * FROM table WHERE ( start_date BETWEEN date_from and date_to ) OR ( end_date BETWEEN date_from and date_to) 
-1
votes
SELECT * FROM table WHERE '2014-01-01' <= Start_date AND '2014-08-13' >= End_date