MySQL中 BIGINT UNSIGNED value is out of range

MYSQL中当两个字段相减时,如果其中一个或两个字段的类型的unsigned无签名类型,

如果想减的值小于0则会报错(BIGINT UNSIGNED value is out of range)
处理办法:

例:select a - b from table

解决方案:select if(a >= b, a - b, - (b - a)) from tbl

猜你喜欢

转载自blog.csdn.net/QJQJLOVE/article/details/108673576
今日推荐