【发布时间】:2016-05-25 02:21:52
【问题描述】:
甲骨文数据库 在 SQL 中:
如何从另一个表的列更新表的一列以及如何在单个查询中连接第一个表的两列
如果 table_1 的 column_1 与 table_2 的 column_A 匹配,则根据 table_2 的 column_B 的值更新 table_1 的 column_2,并将 table_1 的 column_3 和 column_4 连接到 table_1 的 column_5。
我试过了:
UPDATE T1
SET column_2 = T2.column_B,
column5 = T1.column_3 + T1.column_4
FROM table_1 AS T1
JOIN table_2 AS T2
ON T2.column_A = T1.column_1
我没听懂
【问题讨论】:
-
“+”是干什么用的?你是用+连接的吗?
-
如果您想要连接,您应该使用适用于您正在使用的数据库引擎的方法。 Oracle 有关于该主题的文档。
-
如果你有 t1.col3 和 t1.col4 为什么还要连接它们呢?对我来说似乎是多余的