MYSQL Truncated incorrect DOUBLE value

后端 未结 10 1898
广开言路
广开言路 2020-12-04 09:11

When the SQL query below is executed:

UPDATE shop_category 
SET name = \'Secolul XVI - XVIII\' 
    AND name_eng = \'16th to 18th centuries\' 
WHERE category         


        
10条回答
  •  执念已碎
    2020-12-04 09:40

    It seems mysql handles the type casting gracefully with SELECT statements. The shop_id field is of type varchar but the select statements works

    select * from shops where shop_id = 26244317283;
    

    But when you try updating the fields

    update stores set store_url = 'https://test-url.com' where shop_id = 26244317283;
    

    It fails with error Truncated incorrect DOUBLE value: '1t5hxq9'

    You need to put the shop_id 26244317283 in quotes '26244317283' for the query to work since the field is of type varchar not int

    update stores set store_url = 'https://test-url.com' where shop_id = '26244317283';
    

提交回复
热议问题