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.
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) |
Battery coating is the process of applying uniform layers of active materials—such as cathode and…
Let’s face it. Tech buzzwords get thrown around a lot—especially when it comes to how…
In today’s digital world, the boundaries between technology, finance, and innovation are rapidly disappearing. Businesses…
Backyard gatherings like BBQs, family reunions, and garden parties are an exciting way to enjoy…
Marketers are always on the lookout for more effective ways to reach their target audiences.…
Does your phone control your mind more than you control your phone? Modern life exploits…