LEFT Join In SQL


In this post, we are going to learn about the LEFT JOIN clause in SQL and how we can use LEFT JOIN to query the data.

LEFT JOIN in SQL

The LEFT JOIN clause is a  type of join which return all the rows from the left table and matched rows from the right table. In case some rows of the right table don't match the rows of the left table then NULL will be used.

Syntax

SELECT Column_Name
From Table_1 T1
LEFT JOIN Table_2 T2
ON T1.Col = T2.Col


Examples of LEFT JOIN

1) Write a query to implement the LEFT JOIN.


We are going to take the two tables named "Staffs" as T1 and "Stores" as T2. Both the tables contain the primary columns and foreign key columns which help us in the LEFT JOIN. Screenshots of both the tables are given below.



Now we have to see the common values column between both the tables to implement the LEFT JOIN. 

Code


Output



Conditions in ON and WHERE Clause

Questions

Q.1 You have two tables, the left table contains some null values and right table not have any null values. After running the LEFT JOIN query what will be the output?

Q.2 Can LEFT JOIN join the two tables on the basis of the columns which contain the symbol values?

Important to note:



0 Comments