BIGINT UNSIGNED VALUE IS out of range My SQL

后端 未结 9 859
一向
一向 2020-12-18 19:11

I\'m getting the following error

#1690 - BIGINT UNSIGNED value is out of range in \'(legends.spawns.quantity -

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-18 20:00

    I had similar problem, This error also come if our column have 0 value and we try to update it with -1 value.

    In my case MySQL query were Failing if column1 is already have value 0, i.e column1 = 0

    For example:

    UPDATE `table1` SET `column1` = `column1` - 1 WHERE `column2` = XYZ
    

    This give error

    BIGINT UNSIGNED value is out of range in ....

    To counter this problem

    UPDATE `table1`
    SET `column1` = (
        CASE WHEN `column1` < 1
        THEN 0
        ELSE (`column1` - 1)
    end)
    WHERE `column2` = 1
    LIMIT 1
    

提交回复
热议问题