56,687
社区成员
发帖
与我相关
我的任务
分享
select * from table where createtime >= '2014-12-01 12:00:00' and createtime <= '2014-12-01 12:59:59';
select * from table where createtime >= '2014-12-01 12:00:00' and createtime <= '2014-12-01 12:59:59';
和这么写:
select * from table where createtime >= STR_TO_DATE('2014-12-01 12:00:00','%Y-%m-%d %H:%i:%s') and createtime <= STR_TO_DATE('2014-12-01 12:59:59','%Y-%m-%d %H:%i:%s');
有啥却别?要是没区别的话为什么还要有STR_TO_DATE这个函数,还有诸如用UNIX_TIMESTAMP函数转换日期字段/字符串的方式写sql,怎么觉着有点乱呢。其中createtime字段是datetime类型的,这么写sql不会报错,但网上说有可能查的不准,真是这样吗,为什么?