mysql中datetime比较大小问题有如下方法:

方法一:
你也可以:
select * from crowd_textpage where username='carina' and status=4 and unix_timestamp(inputtime) >= unix_timestamp('2013-12-01') and unix_timestamp(inputtime) <= unix_timestamp('2013-12-20'); delete from crowd_textpage where textname like '合肥%' and time>='2014-03-08' and time<'2014-03-09'; update crowd_textpage set status=2 where status=3 and unix_timestamp(time) >= unix_timestamp('2013-12-28') and unix_timestamp(time) <= unix_timestamp('2013-12-31');///更新把2013-12-28号到2013-12-31状态为3的更新成状态为2! 就是用unix_timestamp函数,将字符型的时间,转成unix时间戳。个人觉得这样比较更踏实点儿。 update `crowd_textpage` set status=2 WHERE STATUS =3 AND url LIKE "%58.com%" AND unix_timestamp( time ) >= unix_timestamp( '2014-03-24' ) AND unix_timestamp( time ) <= unix_timestamp( '2014-03-25' ) 方法二:
time1 between '2013-12-01 17:39:05' and '2013-12-020 17:39:52';

方法三:
可以讲datetime类型转换成date类型再进行比较
例如:convert(date,表名.datetime列名) >= convert(date,表名.datetime列名)

三种方法待求证,总之是不要用字符串这么直接比

转载请注明转自:运达's blog 原文地址: http://www.yunda51.com/1130.html