【发布时间】:2018-01-15 14:46:26
【问题描述】:
假设我有一个名为“Table1”的表,其列和值如下
---------------------------
action | component | type |
---------------------------
1 | 2 | 1 |
2 | 3 | 3 |
3 | 4 | 2 |
---------------------------
并且“Table2”与“table1”具有完全相同的结构。
现在我有另一个表“参考”,如下所示
---------------------------
description | id | value |
---------------------------
action | 2 | create|
action | 1 | delete|
action | 3 | update|
component | 2 | c1 |
component | 4 | c2 |
component | 3 | c3 |
type | 2 | t1 |
type | 1 | t2 |
type | 3 | t3 |
---------------------------
现在,我需要通过引用“reference”表中的值将数据从“table1”移动到“table2”。我的结果表应如下所示。
action | component | type |
---------------------------
delete | c1 | t2 |
create | c3 | t3 |
update | c2 | t1 |
---------------------------
请帮助我进行相同的查询。提前致谢。
【问题讨论】:
-
哪个您使用的是 SQL?发帖前你有没有尝试过?
-
实际上我正在尝试这是 hive 查询,而我尝试的是在选择时尝试用 select 语句替换特定列,其中包括带有引用表的 join 语句。但它没有发生。