mysql datetime field with index get a range 'like' vs. 'between and' performance

后端 未结 2 1296
情书的邮戳
情书的邮戳 2021-02-19 19:32

I just find mysql can query datetime using like:

like \'2013-06-12%\'

I think it can not use the index. I Google it, but can not find such subj

2条回答
  •  悲&欢浪女
    2021-02-19 19:55

    One alternative for such cases is to do something like this:

    SELECT *
    FROM subscription t
    WHERE t.active_time BETWEEN '2013-06-30 00:00:00' AND '2013-06-30 23:59:59';
    

    In the end you get all events from that day.

提交回复
热议问题