Comparing date values of CURDATE() with a full timestamp field

后端 未结 2 823
耶瑟儿~
耶瑟儿~ 2021-01-21 09:36

I have a function that is placing timestamp values (YYYY-MM-DD HH:MM:SS) into META_VALUE column of table META.

What I want to do is to compare

2条回答
  •  既然无缘
    2021-01-21 09:52

    SELECT * FROM table WHERE  BETWEEN 'YYYY-MM-DD 00:00:00' AND 'YYYY-MM-DD 23:59:59'
    

    Allways avoid doing calculations on the field if possible: e.g.

    SELECT * FROM table WHERE DATE() = 'YYYY-MM-DD'
    

    will calculate DATE() for ALL rows in that table, so you are really talking wasted cycles here

提交回复
热议问题