/    /  MySQL – EquiJoin

MySQL – EquiJoin

 

MySQL – EquiJoin

When we combine two or more tables according to some common columns and a join condition, we refer to this process as joining. Equijoin is a method of combining tables based on the equality or matching column values of their associated tables.

Equjoin is a type of inner join that returns output by combining two tables based on a common column. By using the common primary field name, this join returns only the data that is available in both tables. Null records and unmatched data are not displayed in the result set.

  • It is not necessary to use the same column names.
  • It is possible for the resultant result to have repeated column names.
  • In addition to joining two tables, we can also join more than two tables together.

Syntax

SELECT column_name (s)  
FROM table_name1, table_name2, ...., table_nameN  
WHERE table_name1.column_name = table_name2.column_name;  

The SELECT keyword is followed by the column names that should be included in the result set. In order to select all columns from both tables, the * operator will be used. The next step is to specify the table names for the join after the FROM keyword, followed by the WHERE and ON conditions.

Example

SELECT dept.emp_no, emp.last_name   
FROM dept_emp AS dept,
employees  AS emp  
WHERE dept.emp_no = emp.emp_no;

join