1.

What is an Equi Join?

Answer»

Equi Joins are a type of INNER Joins where a join is performed between two or more tables using a common column between them. Using the equality sign ( = ), it compares the data in two columns, if the data is the same, it retrieves it.

Syntax:

SELECT * FROM Table1, Table2
WHERE Table1.ColumnName = Table2.ColumnName;

OR

SELECT column_list  FROM Table1, Table2
WHERE Table1.ColumnName = Table2.ColumnName;

OR

SELECT * FROM Table1 JOIN Table2 ON Table1.ColumnName = Table2.ColumnName;
Example: Consider the tables Employee and State.

Employee Table

Emp_NameState_ID
Asha Bisht1
Rohit Sharma1
Karan Tacker2
Karan Oberoi3
Nikhil Bhardwawaj3

State Table

State_IDState_Name
1Madhya Pradesh
2Bangalore
3Uttarakhand
4Rajasthan

Now, lets perform Equi-join using the equality operation and the WHERE clause as follows;

SELECT Emp_Name, State_Name FROM Employee, State WHERE Employee.State_ID = State.State_ID;

Output: 

Emp_NameState_Name
Asha BishtMadhya Pradesh
Rohit SharmaMadhya Pradesh
Karan TackerBangalore
Karan OberoiUttarakhand
Nikhil BharadwajUttarakhand



Discussion

No Comment Found