Mysql ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in..的解决方法
2022/2/24 19:26:50
本文主要是介绍Mysql ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in..的解决方法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
因为2个时间在数据库里设计的都是无符号,但是使用结束时间-开始时间=负数,所以报错
今天在做一个功能的时候,用到两个时间戳相减来做查询条件,由于其两个字段都是unsigned的,并两个的大小是不一样。所以直接相减查询的时候, 就出现ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in..的错误,因为结果可能会出现负数。。。。 过后查资料,发现可以通过下面的方法来解决: mysql> select lastvisit, lastactivity from pre_common_member_status limit 1; +------------+--------------+ | lastvisit | lastactivity | +------------+--------------+ | 1199200260 | 1198336989 | +------------+--------------+ 1 row in set (0.01 sec) mysql> select lastvisit-lastactivity from pre_common_member_status limit 1; +------------------------+ | lastvisit-lastactivity | +------------------------+ | 863271 | +------------------------+ 1 row in set (0.05 sec) mysql> select abs(lastvisit-lastactivity) from pre_common_member_status limit 1; +-----------------------------+ | abs(lastvisit-lastactivity) | +-----------------------------+ | 863271 | +-----------------------------+ 1 row in set (0.03 sec) mysql> select lastactivity-lastvisit from pre_common_member_status limit 1; ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in '(`discuz`.`pre_c ommon_member_status`.`lastactivity` - `discuz`.`pre_common_member_status`.`las tvisit`)' mysql> select cast(lastactivity as signed)-cast(lastvisit as signed) from pre_co mmon_member_status limit 1; +--------------------------------------------------------+ | cast(lastactivity as signed)-cast(lastvisit as signed) | +--------------------------------------------------------+ | -863271 | +--------------------------------------------------------+ 1 row in set (0.02 sec) mysql> select abs(cast(lastactivity as signed)-cast(lastvisit as signed)) from p re_common_member_status limit 1; +-------------------------------------------------------------+ | abs(cast(lastactivity as signed)-cast(lastvisit as signed)) | +-------------------------------------------------------------+ | 863271 | +-------------------------------------------------------------+ 1 row in set (0.00 sec) mysql>
这篇关于Mysql ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in..的解决方法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-04-26MySQL查出时间比实际晚8小时的解决方案
- 2024-04-01JPA不识别MySQL的枚举类型
- 2024-03-30mysql数据库表卡死解决方法
- 2024-03-15MySQL多数据源笔记5-ShardingJDBC实战
- 2024-03-11natural join mysql
- 2024-03-11关于VS2017,VS2015 中利用 EF使用Mysql 不显示数据源问题解决方案
- 2024-02-26mysql 阿里云xb后缀备份文件恢复-icode9专业技术文章分享
- 2024-02-22docker mysql 5.7
- 2024-02-18从 20 多套 MySQL 到 1 套 TiDB丨骏伯网络综合运营管理平台应用实践
- 2024-02-07mysql 外键索引入门介绍,为什么工作中很少有人使用?