MySQL: Equi Join

Profile picture for user arilio666

In MySQL equijoin works in the way of combining two or more tables based on the equality or the matching columns where the '=' sign is used as the comparison operator to define equality with the pair up of WHERE clause.


SELECT * from TableName1, TableName2 WHERE TableName1.commoncolumn = TableName2.commoncolumn;

Let us see clearly in a real-time example where we will be using employees and offices table to merge the matching columns on both using the comparison operator '='.


select * from employees e, offices o where e.office_id = o.office_id;

  • Here from the example output pic, we can confirm now from both the tables of employees and offices we have merged the common matching column based on equality, and thus we can see here that the office_id column is what we wanted to match.

So let's work on a simple exercise where using the same query we will get the salary details of the employees matching with the office_id along with their names and employee id.

Let's check it out.


select  employee_id AS EID, e.first_name, e.last_name,e.salary from employees e, offices o where e.office_id = o.office_id;

  • So from this exercise, we can now see the most wanted columns we preferred and aliased along with the employee's salary details matching with equality to the office_id of the offices' table.