hive sql 外连接
时间: 2023-10-24 21:32:31 浏览: 107
SQL外部连接
在Hive SQL中,外连接用于根据连接条件来返回左表和右表的匹配和非匹配记录。外连接有三种类型: 左外连接、右外连接和满外连接。
左外连接(left outer join)返回左表中的所有记录以及与右表匹配的记录。如果右表中没有匹配的记录,则返回NULL值。
右外连接(right outer join)返回右表中的所有记录以及与左表匹配的记录。如果左表中没有匹配的记录,则返回NULL值。
满外连接(full outer join)返回左表和右表的所有记录,如果左表或右表中没有匹配的记录,则返回NULL值。
下面是示例的Hive SQL语句:
左外连接:
SELECT * FROM teacher t LEFT OUTER JOIN course c ON t.t_id = c.t_id;
右外连接:
SELECT * FROM teacher t RIGHT OUTER JOIN course c ON t.t_id = c.t_id;
满外连接:
SELECT * FROM teacher t FULL OUTER JOIN course c ON t.t_id = c.t_id;<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [hivesql语句练习](https://download.csdn.net/download/weixin_42237911/10833235)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [一张图轻松搞懂Hive中的join(内连接、左外连接、右外连接、满外连接)](https://blog.csdn.net/weixin_43230682/article/details/108100250)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文