表1:
id name desc
-----------------------
1 a abc
2 b def
3 c adf
表格 2:
id name desc
-----------------------
1 x 123
2 y 345
我该如何运行一个SQL UPDATE查询,以便使用相同的id更新Table 1和Table 2的名称和描述?因此,最终结果我会得到:
Table 1:
id name desc
-----------------------
1 x 123
2 y 345
3 c adf
如何在以下数据库中实现此操作:
- SQL Server
- MySQL
- PostgreSQL
- Oracle
FROM
部分可能会更简单:只需FROM table2 WHERE table1.id = table2.id
,并且可以删除每个赋值左侧的别名。 - Andriy MJOIN
中而不是WHERE
中... - The Scrum Meisterupdate a set field1 = concat_ws(' ',field1, table2.middle_name, table2.first_name) from table2 where a.id = table2.fieldX;
刚刚添加了一些函数以展示可能性。 - Peter