开发者

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 

d开发者_如何学JAVAue_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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜