一尘不染

BIGINT UNSIGNED值超出范围

mysql

我收到错误

BIGINT UNSIGNED值超出范围在’(1301980250 - 。。mydb )’news_articles``date

当我运行查询

SELECT *, ((1 / log(1301980250 - date)) * 175) as weight FROM news_articles ORDER BY weight;

删除ORDER BY条件,也将删除错误。我该如何解决?

更新: 日期字段包含UNIX时间戳(例如:1298944082)。我将MySQL从5.0.x升级到5.5.x后开始出现错误

有什么帮助吗?


阅读 1799

收藏
2020-05-17

共1个答案

一尘不染

我最近遇到了这个问题,并找到了最合理的解决方案,可以将任何UNSIGNED整数简单地转换为SIGNED。

 SELECT *, ((1 / log(1301980250 - cast(date as signed)) * 175) as weight FROM news_articles ORDER BY weight
2020-05-17