MYSQL
June 3, 2026 3 min read

Mastering MYSQL Joins: INNER JOIN, LEFT JOIN, and RIGHT JOIN for Efficient Data Combination

HS
HEMANT SINGH
Technical Writer & Educator

Join allows combining records from multiple tables.

  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN

For join concepts, we will take the given tables as an example.

Table: users(Parent table in a join)

idusernameemailpassword
1Amanaman@gmail.com12345
2Kamalkamal@gmail.com12345
3OmOm@gmail.com12345

 

Table: posts(child table in a join)

iduser_idtitlepost
11What is the computerElectronic machine
21WWW stands forWorld wide web
32Who invented HTMLTim Berner Lee
421 MB equivalent to 1024 KB

INNER JOIN

INNER JOIN returns only those records from both tables where condition matched.

Display all records from both tables (users, posts) where user_id is matched.

SELECT users.id, users.username, posts.title, posts.post  FROM users 
INNER JOIN posts 
ON users.id = posts.user_id;
idusernametitlepost
1AmanWhat is the computerElectronic machine
1AmanWWW stands forWorld wide web
2KamalWho invented HTMLTim Berner Lee
2Kamal1 MB equivalent to 1024 KB

 

LEFT JOIN

LEFT JOIN returns all the records from the left table and matching records from the right table.

Fetch all users from the users table and related posts from the posts table.

SELECT users.id, users.username, posts.title, posts.post FROM users
LEFT JOIN posts 
ON users.id = posts.user_id;
idusernametitlepost
1AmanWhat is the computerElectronic machine
1AmanWWW stands forWorld wide web
2KamalWho invented HTMLTim berner lee
2Kamal1 MB equivalent to1024 KB
3OmNULLNULL

 

RIGHT JOIN

RIGHT JOIN return all the records from the right table and match records from the left table.

Fetch all posts from the posts table and related users from the users table.

SELECT  posts.id, posts.title, posts.post, users.username FROM users
RIGHT JOIN posts
ON posts.user_id = users.id;
idtitlepostusername
1What is the computerElectronic machineAman
2WWW stands forWorld wide webAman
3Who invented HTMLTim berner leeKamal
41 MB equivalent to1024 KBKamal