I have a table in mysql db which contains a list of TV Programs of this week. It is something like this.
----------------------------------------------
start_time, tv_program_name isLive
2013-01-19 17:00 sports news
2013-01-19 18:30 NBA....
......
------------------------------------------------
I want to use SQL to find out the current tv program by compare the start_time with now(), and mark the current tv program in db with isLive = 1
I try to use the sql
-------------
SELECT *
FROM tv_programs
ORDER BY ABS( TIMESTAMPDIFF(
MINUTE , start_time, NOW( ) ) ) ASC
-------------
But it is not the right solution because it only return the tv_program which is nearest to the current, not the live tv program that it is playing now.
Can anyone show me some light on this problem?
1 Answer