我想更新 MYSQL 中列的第一个字符
WHERE the format of the string is LIKE '1-%'
将第一个字符更改为“0”。
我已经创建了这个示例并且认为我在正确的轨道上......
UPDATE products
SET
has_roundel = REPLACE(has_roundel, SUBSTRING(has_roundel, 0, 1),'0')
WHERE
has_roundel like '1-%';
最佳答案
MySQL SUBSTRING 不是从 0 开始的。
您可以使用:
UPDATE products
SET
has_roundel = REPLACE(has_roundel, SUBSTRING(has_roundel, 1, 1),'0')
WHERE
has_roundel like '1-%';
或者:
UPDATE products
SET
has_roundel = REPLACE(has_roundel, SUBSTRING(has_roundel, 1),'0')
WHERE
has_roundel like '1-%';
关于MYSQL - 更新列中字符串的第一个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22222427/