I have an attribute in a table that goes 1, 2, 3, 4, 5, ....
. Right now, I'm trying to add .jpg to the file name. That is, it should be 1.jpg, 2.jpg, 3.jpg, 4.jpg,...
.
我在表格中有一个属性,分别为1,2,3,4,5 ......现在,我正在尝试将.jpg添加到文件名中。也就是说,它应该是1.jpg,2.jpg,3.jpg,4.jpg,....
I tried using that command:
我尝试使用该命令:
UPDATE tbl_items set filename = CAST(itemID AS char(10)) + '.jpg'
I'm getting this error
我收到了这个错误
1292 Truncated incorrect DOUBLE value: '.jpg'
1292截断错误的DOUBLE值:'.jpg'
Can anyone tell me what is wrong?
谁能告诉我有什么问题?
1 个解决方案
#1
2
The plus operator isn't valid in MySQL for string concatenation. Instead, try using CONCAT()
:
对于字符串连接,plus运算符在MySQL中无效。相反,尝试使用CONCAT():
UPDATE tbl_items
SET filename = CONCAT(CAST(itemID AS CHAR(10)), '.jpg')
Your current error is probably arising because MySQL assumes you are trying to do arithmetic with either side of the plus operator.
您当前的错误可能是因为MySQL假设您正在尝试对plus运算符的任一侧进行算术运算。
#1
2
The plus operator isn't valid in MySQL for string concatenation. Instead, try using CONCAT()
:
对于字符串连接,plus运算符在MySQL中无效。相反,尝试使用CONCAT():
UPDATE tbl_items
SET filename = CONCAT(CAST(itemID AS CHAR(10)), '.jpg')
Your current error is probably arising because MySQL assumes you are trying to do arithmetic with either side of the plus operator.
您当前的错误可能是因为MySQL假设您正在尝试对plus运算符的任一侧进行算术运算。