带有变量赋值,concat和right的SQL错误

时间:2015-04-01 23:07:02

标签: mysql

我正在尝试通过连接MySQL表中几个单元格的位来生成ID。我想要摆脱 - 和:并且只有ID中的数字。我收到了以下语法错误:

update scan_data
set @scanDate1 = replace(scanDate,'-','')
set @scanTime1 = replace(scanTime,'-','')
scanID = concat(right(scanContent,2),right(@scanDate1,2),right(@scanTime1,2))

我需要改变什么?

1 个答案:

答案 0 :(得分:0)

试试这个

update scan_data set scanID = concat(right(scanContent, 2),
                                     right(replace(scanDate,'-',''), 2),
                                     right(replace(scanTime,'-',''), 2)
                                    );