Mysql Query error: BIGINT UNSIGNED value is out of range in..解决方法(转)

原文:https://blog.51cto.com/bstdn/1951064

1、问题

  • 当字段类型为 unsigned 时,使用相关结果为负值时就会报错,报错如下:
BIGINT UNSIGNED value is out of range in ..1.

2、解决

  • 使用 cast() 修改字段类型为 signed
select cast(quantity as signed) - cast(quantity2 as signed) from order_details
posted @ 2023-05-08 14:11  pine007  阅读(286)  评论(0编辑  收藏  举报