SQL Joins – Left, Right, Inner And Full Outer Join – SQL Tutorial

SQL Joins:

SQL joins are used to combine rows from two or more tables. Here we are going to discuss the following Joins using these you could return the data from two relational tables.

Must See: Cheat Sheet – Joins SQL

Types of SQL Joins:

i. INNER JOIN
ii. LEFT JOIN
iii. RIGHT JOIN
iv. OUTER JOIN

Must see: SQL Cheat Sheet Joins

INNER JOIN:

This query will return all of the records in the left table (table A) that have a matching record in the right table (table B).

 Sql Joins Inner Join

LEFT JOIN:

This query will return all of the records in the left table (table A) regardless if any of those records have a match in the right table (table B). It will also return any matching records from the right table.

Sql Joins Left Join

RIGHT JOIN:

This query will return all of the records in the right table (table B) regardless if any of those records have a match in the left table (table A). It will also return any matching records from the left table.

Sql Joins Right Join

FULL OUTER JOIN:

The FULL OUTER JOIN keyword returns all the rows from the left table (Customers), and all the rows from the right table (Orders). If there are rows in “Customers” that do not have matches in “Orders”, or if there are rows in “Orders” that do not have matches in “Customers”, those rows will be listed as well.

This Join can also be referred to as a FULL OUTER JOIN or a FULL JOIN. This query will return all of the records from both tables, joining records from the left table (table A) that match records from the right table (table B).

Sql Joins Full Join

Note on the OUTER JOIN that the inner joined records are returned first, followed by the right joined records, and then finally the left joined records (at least, that’s how my Microsoft SQL Server did it; this, of course, is without using any ORDER BY statement).

In the next tutorial, we will see AGGREGATE FUNCTIONS In SQL

Check out the complete SQL Tutorial by clicking on below link:

SQL Tutorial – Complete

If you are not regular reader of my blog then I highly recommend you to signup for the free email newsletter using the below link.

Get our latest blog posts delivered to your inbox

Subscribe and get popular blog posts about software testing industry.

Rajkumar

Leave a Comment

Share via
Copy link
Powered by Social Snap