OUTER JOIN

Besides INNER JOIN, HQL also supports regular OUTER JOIN and FULL JOIN. The logic of such a join is the same as what's in the SQL. The following table summarizes the differences between common joins. Here, we assume table_m has m rows and table_n has n rows with one-to-one mapping:

Join type Logic Rows returned

table_m

JOIN table_n

This returns all rows matched in both tables. m ∩ n

table_m 

LEFT JOIN table_n

This returns all rows in the left table and matched rows in the right table. If there is no match in the right table, it returns NULL in the right table. m

table_m 

RIGHT JOIN table_n

This returns all rows in the right table and matched rows in the left table. If there is no match in the left table, it returns ...

Get Apache Hive Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.