小编Prv*_*vul的帖子

mysql选择a和b之间的时间戳,返回全部或0个时间戳

试过这个

select * from table where timestamp_field between 1330560000 and 1336170420
Run Code Online (Sandbox Code Playgroud)

还有这个

select * from table where timestamp_field >=1330560000 and timestamp_field<=1336170420
Run Code Online (Sandbox Code Playgroud)

都返回空结果集.

但是这个

select * from table where timestamp_field >= 1330560000
Run Code Online (Sandbox Code Playgroud)

返回所有行

使事情更荒谬

select * from table where timestamp_field <= 1336170420
Run Code Online (Sandbox Code Playgroud)

返回空结果集.

当然,在1336170420 = 4.may 2012之前,之间和之后存在时间戳值.并且1330560000 = 1.march 2012.

时间戳值是可以的,至少phpmyadmin显示正确的(人类可读的)日期时间值.我通过解析字符串来创建时间戳

UPDATE table SET timestamp_field = STR_TO_DATE(timestamp_string, '%d.%m.%Y')
Run Code Online (Sandbox Code Playgroud)

猜猜我错过了什么,却找不到什么!?

mysql timestamp

4
推荐指数
1
解决办法
8206
查看次数

标签 统计

mysql ×1

timestamp ×1