MySQL: Left Join

Profile picture for user arilio666

In MySQL, we have the concept of LEFT JOIN where the following query will join a table name from the left side with the table queried on the right side.

Here, the joining works in the way of all the left table content will be displayed and the right table content will be displayed with the respective matching pair of the left table content thus called the LEFT JOIN.


SELECT * from TableName1 LEFT JOIN TableName2 ON TableName1.CommonColumn1 = TableName2.CommonColumn1;

The table named on the left side of the query that is TableName1 from syntax is the left table so the pairing will begin by matching the common and ignoring what is not there in the left from the right table content.

So let us dive into some real-time practical examples.

For this example, we will be working with the products table as left and the products extra table as of right.

Today we will be matching the products based on the product_id from the products table with the products extra table.


select * from products left join productsextra on products.product_id = productsextra.product_id;

  • So from here, we get the matching content from the right table about the table where the product_id is matched precisely ignoring the other existing data where product_id of it's is 12,13,15,16.
  • Because there is no entry of the product_id in the left product table so the LEFT JOIN ignores the content which does not match.