Joining tables
BigQuery supports a variety of join types that can be used to combine data from two or more tables. The most common join types are inner joins, outer joins, and self joins.
Inner joins
An inner join returns rows that match the JOIN
condition from both tables. It only returns the rows where the joining condition is met on both tables. The JOIN
condition is a Boolean expression that compares values in the two tables. For example, the following query joins the customers
table and the orders
table on the customer_id
column:
SELECT customer_id, name, order_id, order_date FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id
This query will return all rows from the customers
table that have a matching row in the orders
table. Inner joins are useful when you want to focus on the intersection of data between tables.
Outer joins
An outer join returns all rows from the left table, even if there is no matching row in the right table. The...