web123456

hive multi-table association

Multi-table join instructions


select * from (select userId from table_a where dt=20160731) a join (select userId from table_b where dt=20160731) b  on = join (select userId from table_c where dt=20160731) c on =
Equivalent to
select * from (select userId from table_a where dt=20160731) a join (select userId from table_b where dt=20160731) b  on = join (select userId from table_c where dt=20160731) c on =
Equivalent to
select * from (select userId from table_a where dt=20160731) a join (select userId from table_b where dt=20160731) b  on = join (select userId from table_c where dt=20160731) c on = and =




Summarize:
You can regard the association of a and b table join as a new table table_j. The table_j table has two columns and is associated with the c table.






If the left outer join effect is the same, it will only be connected to the first column of table_j or the second column for the last on link condition.


The second column userId() equivalent to table_j is associated with c, regardless of whether table b can be associated.

select * from 
(select userId from table_a where dt=20160731) a 
left outer join (select userId from table_b where dt=20160731) b  on = 
left outer join (select userId from table_c where dt=20160731) c on =




The second column userId() equivalent to table_j is associated with c, regardless of whether table a can be associated.
select * from 
(select userId from table_a where dt=20160731) a 
left outer join (select userId from table_b where dt=20160731) b  on = 
left outer join (select userId from table_c where dt=20160731) c on =




The first column equivalent to table_j is associated with the second column userId() and c, and it is required to be associated at the same time.
select * from 
(select userId from table_a where dt=20160731) a 
left outer join (select userId from table_b where dt=20160731) b  on =  
left outer join (select userId from table_c where dt=20160731) c on = and =