select *
from tb
where substring(time,':',1)>='7:30'
order by id
limit 2;
[/Quote]
可能rucypli 没有理解我的意思,我要的是比7:30的最近的一条记录和比7:30小的一条记录,你的答案肯定是有问题的,如果我有多条7:30之前的记录,那我就找不到7:30之后的记录了,那不过同样感谢你!
select *
from table1 a
where (`TIME`<now() and not exists (select 1 from table1 where `TIME`<now() and `TIME`>a.`TIME`))
or (`TIME`>now() and not exists (select 1 from table1 where `TIME`>now() and `TIME`<a.`TIME`))