sql - MySQL Select next 2 rows greater than time -
i have database has stored time values train schedule. table:
create table if not exists `bahn_hausen` ( `id` int(11) unsigned not null auto_increment, `time` time not null, `day` varchar(12) not null, primary key (`id`) ) engine=myisam default charset=latin1 auto_increment=132 ;
now want select next 2 rows after now():
select time bahn_hausen time > now() limit 2
the problem when > last time today (23:45:00), there no row selected. however, want select next 2 values of course (00:15:00 , 00:45:00). works correctly when now() >= 0:00:00
*[edit]*for clarification: problem having sql doesn't recognize 00:15 greater 23:45.
how do this? help.
your query there. need order by
:
select time bahn_hausen order time > now() desc, time limit 2;
Comments
Post a Comment