SQL LEFT JOIN

Video Tutorial
FREE
 Inner, Left, Right and Outer joins thumbnail
This video belongs to
DBMS Course - Master the Fundamentals and Advanced Concepts
16 modules
Certificate
Topics Covered

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Overview

In this article, you will learn how to use the LEFT JOIN clause in SQL to combine data from two or more tables based on a specific join condition. The article gives a thorough explanation of the syntax and application of the LEFT JOIN clause. It also includes examples of how to use it to retrieve data from multiple tables. By the end of the article, readers should have a solid understanding of using the LEFT JOIN clause effectively in their SQL queries.

What is LEFT JOIN in SQL?

A left join is a type of join in SQL that returns all the records from the left table and only those from the right table, which are matched to records in the left table.

For example, let us take the Customers table.

The Orders table for each customer could be viewed accordingly.

Now, let us join these two tables using the LEFT JOIN in SQL.

The joined table would look like this:

This means that a left join returns all the values from the left table (i.e., the ORDERS table in this case), plus matched values from the right table or NULL in case of no matching join predicate.

For example, look at the Venn diagram below.

Left join SQL

Assume that you have two tables, Table A and Table B. A left join between Tables A and B would mean that all the records from Table A would be displayed, along with only those records from Table B, which are matched to Table A.

Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science

Syntax of LEFT JOIN

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

LEFT JOIN in SQL Example

Student Table

student_nameageclassroll_no
A Kumar1812r1
S Sinha1911r2
G Prasad1812r3

Language_Marks Table

r_nosubjectmarks
r1French90
r2German80
r3Hindi85

To perform a left join on these two tables, we will use the following SQL query:

Abstract of Code

The above query displays the student_name, age, and class columns from the student table, and the subject, marks columns from the language_marks table. Abstract of Code

Thus, the left table is joined to the right table using the *r_no* field.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Why Do We Need LEFT JOIN in SQL?

A left join is useful when a user wants to extract all the records from the left table. Even if there are no matched records in the right table, all the records from the left table would be displayed.

In the Customers and Orders table examples, we see that a left join is established on the Orders table and returns all the specified rows from the left table.

Conclusion

  1. LEFT JOIN in SQL are joins used to join the records from the left table to the matched records in the right table.
  2. Even if there are no matched records in the right table, the records from the left table are extracted.
  3. It is also called left outer join.