select * from table where starttime<=curtime() and endtime>=curtime();

 

开始时间小于结束时间 (时间段在一天内)
开始时间大于结束时间 (时间段跨天<不在同一天>)
select id, case when starttime<=endtime then 1 else 0 end as s1
from table
where  (s1=1)  and  curtime() >= starttime and curtime() <= endtime ;
untion all
select id, case when starttime<=endtime then 1 else 0 end as s1
from table
where  (s1=0)  and  curtime() <= starttime and curtime() >= endtime ;

 

相关文章:

  • 2021-05-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案