人工智能,零基础入门!http://www.captainbed.net/inner
单纯的字符串比较结果不精确.【1】select * from tableName where times> '2088/12/8 10:02:40';(×)
转换函数如下(数据库为varchar):
select * from h_hotelcontext where now() between STR_TO_DATE(Start_time,'%Y-%m-%d %H:%i:%s') and STR_TO_DATE(End_time,'%Y-%m-%d %H:%i:%s');
【2】select max(addtime) from student where stuid='9';(×)
select max(STR_TO_DATE( addtime,'%Y/%m/%d %H:%i:%s')) from student where stuid='9';
有些时候%Y-%m-%d %H:%i:%s 这种转换格式并不能得到正确的结果,原因待查