0% found this document useful (0 votes)
135 views

SQL Left Join

SQL LEFT JOIN returns all rows from the left table mentioned in the LEFT JOIN clause. If there are no matching rows in the right table, NULL values will be returned. It joins two tables - SalesDetails and ClientDetails - on their common ClientID field and returns OrderID, ClientName, and OrderDate, ordered by OrderDate. LEFT JOIN allows retrieval of all rows from the left table even if they have no matches in the right table.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views

SQL Left Join

SQL LEFT JOIN returns all rows from the left table mentioned in the LEFT JOIN clause. If there are no matching rows in the right table, NULL values will be returned. It joins two tables - SalesDetails and ClientDetails - on their common ClientID field and returns OrderID, ClientName, and OrderDate, ordered by OrderDate. LEFT JOIN allows retrieval of all rows from the left table even if they have no matches in the right table.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL LEFT JOIN

SQL LEFT JOIN returns all the rows from the left table mentioned with the LEFT JOIN
clause. If there are no matching rows in right table then output rows will return NULL
values.

Syntax
SELECT columnName(s)
FROM Table1 LEFT JOIN Table2
ON Table1.columnName = Table2.columnName
Refer below image to understand LEFT JOIN, here green part is output for LEFT JOIN.

Here we will consider one example for LEFT JOIN condition where we will use
two tables named as SalesDetails and ClientDetails.
Table Name: SalesDetails
Table Name: ClientDetails

As you can see, first table has 8 records and second table has 10 records. From above
two tables, we need columns OrderID and OrderDate from SalesDetails table and one
column ClientName from ClientDetails table and sorted in ascending
order by OrderDate column. So to get the output from two tables we will use LEFT JOIN
query as given below.

SELECT SalesDetails.OrderID, ClientDetails.ClientName, SalesDetails.OrderDate


FROM SalesDetails LEFT JOIN ClientDetails
ON SalesDetails.ClientID = ClientDetails.ClientID
ORDER BY OrderDate

So, in LEFT JOIN all the records are returned from the table which is mentioned in left side.

Also Refer:
 SQL JOINS
 SQL INNER JOIN
 SQL RIGHT JOIN
 SQL FULL JOIN
 SQL CROSS JOIN

You might also like