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>
答案 0 :(得分:0)
我使用concat函数而不是concat运算符&#39; ||&#39;
的MySQL&GT;更新GSLAB set empid = concat(substr(empid,1,2),&#39; - &#39;,substr(empid,4,15))其中substr(empid,1,3)&lt;&gt;&# 39; - &#39 ;;