MySQL 'Truncated incorrect INTEGER value'

前端 未结 6 1450
野趣味
野趣味 2020-12-11 01:57

I\'m getting an odd \'Truncated incorrect INTEGER value\' error when I run the following UPDATE query:

update tbl
set projectNumber = right(comments, 7)
wher         


        
6条回答
  •  抹茶落季
    2020-12-11 02:33

    As stated in other answers, this is an error as of 2019, which prevents the query from running. To run the query even if there are strings that cannot be converted to numbers, simply use UPDATE IGNORE.

    So for example a minimal version of the original code:

    UPDATE IGNORE tbl
    SET projectNumber = RIGHT(comments, 7)
    WHERE CONVERT(RIGHT(COMMENTS, 7), SIGNED INTEGER) > 0
    

提交回复
热议问题