Difference Between Inner Join and Left Join

What’s the difference between inner join and left join in MySql ?  In relational databases (Such as MySql etc.) concept of join is very important. In this tutorial, I’ll explain inner join and left join.

MySql Interview Questions.

Why we use Join  ?

Join are used when we need to retrieve data from multiple tables. In relational databases, We need to retrieve data from more than one tables in that case join is very helpful.

Join matches rows in one table with rows in another table based on join-predicate (or condition) and gives you the output that contains columns from both or either tables.

I hope you understand the purpose of join and their usage. Now let’s understand the difference between inner join and left join.

How to find second highest salary in MySql.

Difference Between Inner Join and Left Join

To understand the concept of inner join and left join, let’s create two tables (emp_data and emp_salary). Let’s insert some dummy values.

The first table is created successfully. Now, let’s create a second table emp_salary.

So both tables are created successfully.

Inner Join

When we use inner join in a query, it selects all rows from both the tables which are common (or match) based upon the join-predicate (or condition).

How to connect MySql database using PHP.

Inner join of table A and B gives all the record that is common in both the tables.

Subscribe Our Tutorials

Get Latest Updates on Facebook

Inner Join Explained


We get common rows between two tables as an output. JOIN is a shorter version of INNER JOIN. There is no difference between join and inner join keyword, they both are equal in performance as well as implementation.


Left join for tables A and B, gives all records of the left table (which is A) even if the condition does not find any matching record in a second table (which is B). The result is NULL for the right table if there is no match.

Left Join

output –

Let’s look at the output, there is no record for id 2 and 3 (smith and Amit) in the emp_salary table, In that case, NULL value is returned.

How to compare NULL value in MySql.


I hope after reading this tutorial, you understand the difference between inner join and left join. If you want to add something, please let us know by your comments.

About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.
Tagged , . Bookmark the permalink.