如何用項目名稱替換'projectId'列中的值,假定名稱爲'project'的另一個表和兩個表與僱員輸出的'projectId'列':'後面提到的數字相關。需要如何使用另一個表中的另一個值更新mysql列?
+----+-----------------------+
| id | projectId |
+----+-----------------------+
| 1 | project:internProject |
+----+-----------------------+
步驟::
> select * from employee;
+----+-----------+
| id | projectId |
+----+-----------+
| 1 | project:1 |
+----+-----------+
希望的輸出
提取整數[完成]
update employee SET projectId = substring_index(projectId,':', -1);
更新專案編號與名稱[不知道:(]
update employee SET projectId = concat('project:', select projectName from projects where projects.projectID = employee.projectId);
感謝您的回答,項目是恆定的 –