Categories
MySQL

Understanding MySQL LEFT JOIN

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.

You may like:  Optimize a MySQL database

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 –

idnamecourse
1A1
2B2
3C2
4D5
5E(NULL)

`course` table –

idname
1HTML
2CSS
3JavaScript
4PHP
5Ajax

So, the result will be:

user.namecourse.name
AHTML
BCSS
CCSS
DAjax
E(NULL)
Avatar for Namaste UI (Author)

By Namaste UI (Author)

Namaste UI collaborates closely with clients to develop tailored guest posting strategies that align with their unique goals and target audiences. Their commitment to delivering high-quality, niche-specific content ensures that each guest post not only meets but exceeds the expectations of both clients and the hosting platforms. Connect with us on social media for the latest updates on guest posting trends, outreach strategies, and digital marketing tips. For any types of guest posting services, contact us on info[at]namasteui.com.

Leave a Reply

Your email address will not be published. Required fields are marked *