我有一个关于数据库查询的问题。请参考下表。
Table : 1 ID Country 1 x 2 y 3 z 4 k Table : 2 eng fre fre1 fre2 x x x1 k y t x2 n z Output Table id country 1 x 2 x1 3 x2 4 x1
如何在Hive中实现这一点?非常感谢你的帮助。
dced5bon1#
您可以加入三次,但速度可能很慢:
select a.id, coalesce(b.eng, c.eng, d.eng) as Country from table_1 a left join table_2 b on a.country=b.fre left join table_2 c on a.country=c.fre1 left join table_2 d on a.country=d.fre2 ;
1条答案
按热度按时间dced5bon1#
您可以加入三次,但速度可能很慢: