MySQL

Understanding MySQL LEFT JOIN

Share

MySQL LEFT JOIN allows you to get result set from two or more tables for certain matches.

Suppose you have two tables i.e. A and B. So if you join A to B using left join then all rows from the A tables will be displayed with matches a row from the B table.

Example of MySQL LEFT JOIN:

SELECT user.name, course.name FROM `user` LEFT JOIN `course` on user.course = course.id;

Here all rows from user tables will be displayed and only matches rows will be displayed from order table.

Read Also: Compare two tables in MySQL

Lets see below example:

`user` table –

id name course
1 A 1
2 B 2
3 C 2
4 D 5
5 E (NULL)

`course` table –

id name
1 HTML
2 CSS
3 JavaScript
4 PHP
5 Ajax

So, the result will be:

user.name course.name
A HTML
B CSS
C CSS
D Ajax
E (NULL)

Recent Posts

Warm Comfort: Choosing the Best Hot Water Bottle for Cozy Nights

Introduction: As the chill of winter settles in or a bout of cold weather strikes,…

15 hours ago

One Location, Different Perspectives: The Allure of Dubai Marina Apartments

Nestled along the glittering waterfront of the City of Gold, Dubai Marina beckons to discerning…

15 hours ago

Role Of Gojek Clone In Growth Campaigns For Your Business

When was the last time you heard that a clone app like Gojek could efficiently…

21 hours ago

How to Optimize Your E-Commerce Pages and Improve UX?

The e-commerce market is growing and evolving at a rapid pace. More and more people…

1 day ago

What Not to Do When Navigating Through a Personal Injury Claim?

Navigating through a personal injury claim can be a complex and daunting process. If you've…

2 days ago

Overview of Reputation, Services, and Features of IplWin

IplWin stands as a reliable and enthralling platform for Indian punters, offering a captivating blend…

4 days ago