我有一个巨大的来自特定供应商的产品表,其中有一个 UPC 列。我需要将这些产品的 UPC 与其他供应商区分开来。目前的想法是在所有这些 UPC 前加上字母 a
。
UPDATE abc_items SET upc = 'a' + upc
这基本上是我想象的做这样的事情的方式,但我知道它行不通。
最佳答案
只需使用 CONCAT功能。
CONCAT(str1,str2,...)
Returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are nonbinary strings, the result is a nonbinary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent nonbinary string form.
UPDATE abc_items SET upc = CONCAT('k', upc)
关于mysql - 如何将字符串添加到 MySQL 中的字段值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45962993/