Professional Documents
Culture Documents
SQL JOIN
An SQL JOIN clause is used to combine rows from two or more tables, based
on a common field between them.
The most common type of join is: SQL INNER JOIN (simple join). An SQL
INNER JOIN returns all rows from multiple tables where the join condition is
met.
JOIN Syntax:
CUSTOMERS.ID = ORDERS.CUSTOMER_ID
Now, let us join these two tables using LEFT JOIN as follows:
SQL> SELECT ID, NAME, AMOUNT, DATE
FROM CUSTOMERS
LEFT JOIN ORDERS
ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
A FULL OUTER JOIN is neither "left" nor "right" it's both! It includes all
the rows from both of the tables or result sets participating in the JOIN.
When no matching rows exist for rows on the "left" side of the JOIN, you
see Null values from the result set on the "right." Conversely, when no
matching rows exist for rows on the "right" side of the JOIN, you see Null
values from the result set on the "left."
SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name=table2.column_name;