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

Jackpotjoy: The UK Beloved Online Casino

Welcome to your ultimate guide to Jackpot joy, the crown jewel of UK online casinos!…

2 days ago

Comparative Analysis of Hybrid Mobile App Development Frameworks

The demand for mobile apps has risen rapidly. The reason? The modern customers proactively rely…

3 days ago

The Rise of Electric Cars in Modern Mobility

In recent years, a significant shift has occurred in the automotive industry as electric vehicles…

3 days ago

Top 3 South Goa beaches worth visiting in summers

Goa is a tiny emerald state of India which is quite famous for attracting tourists…

3 days ago

Unveiling the Mystery: How Long Do Shrooms Last and What to Expect from a Trip

Introduction: Embarking on a psychedelic journey with magic mushrooms, or "shrooms," can be an enlightening…

3 days ago

5 Techniques to Boost Productivity Through Technology Integration

Early technology adopters often reap the rewards of taking a chance. Let’s take a look…

3 days ago