简体   繁体   中英

compare between two dates

i have a course table and a course due dates table like this

course_id | course_name 
1           A
2           B 

due_id | start_date | end_date    course_id 
1        2011-02-01   2011-02-28  1
2        2011-03-01   2011-03-15  1

now what i am trying to do from last tow day that write a query or code that will show a course name with current date session.for example if current date is betwen start and end date course should come like this and if its in next date session it should come with next due_id

course_id | course_name | due_id
1           A           | 1

if this database structure is wrong for this please let me know

thanks for help

SELECT course.course_name, due_dates.course_id, due_id
FROM course
INNER JOIN due_dates ON course.course_id = due_dates.course_id
WHERE now() BETWEEN start_date and 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM