hive-连接查询

  • 内连接查询
hive> select * from customer as c , orderInfo as o where c.id = o.cid;
11      tom1    1       cc      price1  11
12      tom2    2       dd      price2  12
12      tom2    3       ss      price3  12
13      tom3    4       ff      price4  13
  • 左连接查询
hive> select * from customer c left join orderInfo o on c.id = o.cid;#以c.id为主  展示所有的c.id
11      tom1    1       cc      price1  11
12      tom2    2       dd      price2  12
12      tom2    3       ss      price3  12
13      tom3    4       ff      price4  13
14      tom4    NULL    NULL    NULL    NULL
15      tom5    NULL    NULL    NULL    NULL
  • 右连接查询
hive> select * from customer c right join orderInfo o on c.id = o.cid;#以o.id为主  展示所有的o.id
11      tom1    1       cc      price1  11
12      tom2    2       dd      price2  12
12      tom2    3       ss      price3  12
13      tom3    4       ff      price4  13
  • 全连接查询
hive> select * from customer c full join orderInfo o on o.cid = c.id;#保留所有基表的数据
11      tom1    1       cc      price1  11
12      tom2    3       ss      price3  12
12      tom2    2       dd      price2  12
13      tom3    4       ff      price4  13
14      tom4    NULL    NULL    NULL    NULL
15      tom5    NULL    NULL    NULL    NULL
欢迎关注我的公众号:小秋的博客 CSDN博客:https://blog.csdn.net/xiaoqiu_cr github:https://github.com/crr121 联系邮箱:rongchen633@gmail.com 有什么问题可以给我留言噢~
原文地址:https://www.cnblogs.com/flyingcr/p/10326858.html