Returns rows where there is a match in both tables.
Returns all rows from the left table, even if there is no match in the
right table.
The ON clause is used to specify the join condition.
The ON clause is used to specify the join condition, and the
OUTER keyword is used to specify the type of outer join.
The WHERE clause can be used to filter the results of the join.
The WHERE clause can be used to filter the results of the join, but it cannot be used to change the rows that are returned by the outer join.
The INNER JOIN keyword is used to create an inner join.
The LEFT JOIN, RIGHT JOIN, and FULL JOIN keywords are used to create outer joins.
Here are some examples of how inner joins and outer joins can be used:
Inner join: To find all customers who have placed an order, you would use an inner join on the
customers and orders tables. The ON clause would specify that the
customer_id column in the customers table matches the
customer_id column in the orders table.
Left outer join: To find all customers, regardless of whether they have placed an order, you would use a left outer join on the
customers and orders tables. The ON clause would specify that the
customer_id column in the customers table matches the
customer_id column in the orders table. The left outer join would return all rows from the
customers table, even if there is no match in the orders table.
Right outer join: To find all orders, regardless of whether they have a corresponding customer, you would use a right outer join on the
customers and orders tables. The ON clause would specify that the
customer_id column in the customers table matches the
customer_id column in the orders table. The right outer join would return all rows from the
orders table, even if there is no match in the customers table.
Full outer join: To find all customers and orders, regardless of whether there is a match between them, you would use a full outer join on the
customers and orders tables. The ON clause would specify that the
customer_id column in the customers table matches the
customer_id column in the orders table. The full outer join would return all rows from both tables, even if there is no match between them.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Sure. Here are the key differences between inner joins and outer joins in SQL:
Here are some examples of how inner joins and outer joins can be used:
customersandorderstables. TheONclause would specify that thecustomer_idcolumn in thecustomerstable matches thecustomer_idcolumn in theorderstable.customersandorderstables. TheONclause would specify that thecustomer_idcolumn in thecustomerstable matches thecustomer_idcolumn in theorderstable. The left outer join would return all rows from thecustomerstable, even if there is no match in theorderstable.customersandorderstables. TheONclause would specify that thecustomer_idcolumn in thecustomerstable matches thecustomer_idcolumn in theorderstable. The right outer join would return all rows from theorderstable, even if there is no match in thecustomerstable.customersandorderstables. TheONclause would specify that thecustomer_idcolumn in thecustomerstable matches thecustomer_idcolumn in theorderstable. The full outer join would return all rows from both tables, even if there is no match between them.