【发布时间】:2021-09-10 10:50:39
【问题描述】:
我有两个没有匹配值的表 表 1
| Col1 | Col2 | Col3 |
|---|---|---|
| 101 | 111 | AAA |
| 102 | 222 | BBB |
表 2
| Col1 | Col2 | Col3 |
|---|---|---|
| 103 | 333 | CCC |
我想更新下面的表 2,这意味着对于 103,我想要表 1 中的 101 个值
| Col1 | Col2 | Col3 |
|---|---|---|
| 103 | 111 | AAA |
我用过
update table 2
set col2=(select col2 from table 1 where col1=101),
col3=(select col3 from table 1 where col1=101) where col1=103.
除此之外,还有其他查询可以使用吗?
【问题讨论】:
标签: sql sql-server sql-server-2008