BIGINT UNSIGNED VALUE IS out of range My SQL

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

I\'m getting the following error

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

相关标签:
9条回答
  • 2020-12-18 19:45

    I had the same problem, it occurred on a JOIN and couldn't figure out what was going on, in the end it was typo in the ON clause where I placed a minus sign instead of an equal sign. Might be stupid but I just didn't see it for about 30 minutes and maybe this could help someone!!!

    0 讨论(0)
  • 2020-12-18 19:46

    I actualy found that question why I was searching for solution. If you have same problem as I do, try disabling "unsigned" parameter.

    It is quite possible that your code fails here:

    (
    quantity - COUNT( game_moblist.spawn_id )
    )
    

    because if result of that matematic operation is less than zero it will fail with "unsigned" parameter.

    0 讨论(0)
  • 2020-12-18 19:47

    sql_mode worked in the MySQL client and Adminer, but not in CodeIgniter, where it counts. Casting didn't help either.

    A simple arithmetic operation did the trick:

    error

    id - id_ex*1000000000 = id_sm
    

    works

    id_sm + id_ex*1000000000 = id
    
    0 讨论(0)
  • 2020-12-18 19:56

    I don’t quite understand why everyone is saying unsigned. I have a special value in sql and also reported this error. I did it by converting this value to decimal.

    cast(1000000000000000000 AS DECIMAL ( 35, 2 ))
    
    0 讨论(0)
  • 2020-12-18 19:59

    To generalise the rule, MySQL will now refuse to substract an UNSIGNED operand from a SIGNED one.

    Example : SELECT A - B; will fail if A is SIGNED whereas B is UNSIGNED.

    Workarounds: Add 1.0 factor to the signed operand, so it implicitly casts it to FLOAT, or use CAST (B AS SIGNED), or even swap (B - A) and change the algorithm accordingly.

    0 讨论(0)
  • 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
    
    0 讨论(0)
提交回复
热议问题