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?
使用mysql的BETWEEN关键字
SELECT * FROM table WHERE ( start_date BETWEEN date_from and date_to ) OR ( end_date BETWEEN date_from and date_to)
SELECT * FROM table WHERE '2014-01-01' <= Start_date AND '2014-08-13' >= End_date
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.