user382538
user382538

Reputation:

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

Upvotes: 1

Views: 569

Answers (1)

Marc B
Marc B

Reputation: 360572

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;

Upvotes: 3

Related Questions