Concat两个表列并更新一个结果

RYN*_*RYN 6 sql merge concatenation

我有两列的表,我需要连接这两个并用结果更新第一列.
例如假设这是我的表:

+----+-------+-------+
| id | col1  | col2  |
+----+-------+-------+
|  1 | text1 | text2 |
+----+-------+-------+
|  2 | text3 | text4 |
+----+-------+-------+
Run Code Online (Sandbox Code Playgroud)

连接后我的表应该是:

+----+-------------+-------+
| id |    col1     | col2  |
+----+-------------+-------+
|  1 | text1.text2 | text2 |
+----+-------------+-------+
|  2 | text3.text4 | text4 |
+----+-------------+-------+
Run Code Online (Sandbox Code Playgroud)

我怎么能用SQL做到这一点?

Mar*_*rco 13

试试这个(对于MySQL)

UPDATE your_table
SET col1 = CONCAT_WS('.', col1, col2)
Run Code Online (Sandbox Code Playgroud)

这适用于MS-SQL

UPDATE your_table
SET col1 =col1 || "." || col2
Run Code Online (Sandbox Code Playgroud)