mysql> select * from GSLAB;
+--------+--------------+
| empid | destignation |
+--------+--------------+
| GS101 | Manager |
| GS102 | ABC |
| GS-103 | SAS |
| GS-104 | dsSAS |
| GS105 | EWSAS |
| GS106 | EWQAS |
+--------+--------------+
6 rows in set (0.00 sec)
mysql> update GSLAB set empid= substr(empid,4,15)||substr(empid,1,2)||'-' where empid substr(empid,1,3)<>'-';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'substr(empid,1,3)<>'-'' at line 1
mysql>
最佳答案
我使用 concat 函数而不是 concat 运算符“||”
mysql> 更新 GSLAB set empid= concat(substr(empid,1,2),'-',substr(empid,4,15)) 其中 substr(empid,1,3)<>'-';
关于mysql - 当我尝试将行更新到表时,出现以下错误 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43169195/