w3resource logo


Sql equi join

SQL Equi Join

rating Average rating 7 out of 10. Total 123 users rated.

<<PreviousNext>>

What is Equi Join in SQL?

SQL EQUI JOIN performs a JOIN against equality or matching column(s) values of the associated tables. An equal sign (=) is used as comparison operator in the where clause to refer equality.

You may also perform EQUI JOIN by using JOIN keyword followed by ON keyword and then specifying names of the columns along with their associated tables to check equality.

Syntax

SELECT column_list 
FROM table1, table2....
WHERE table1.column_name =
table2.column_name; 

Parameters

Name Description
table1, table2 Tables participating in joining.
column_list List of columns you want to come in the result.
column_name Column whose value's equality is checked.

Syntax

SELECT *
FROM table1 
JOIN table2
[ON (join_condition)]

Parameters

Name Description
table1, table2 Tables participating in joining.
join_condition Some condition. This is optional.

Example

Here is an example of Equi Join in SQL.

Sample table : agents

Sample table : customer

To get 'agent_name' column from 'agents' table and 'cust_name' and 'cust_city' columns from 'customer' table after joining said two tables with following condition -

1. 'working_area' of 'agents' and 'cust_city' of 'customer' table must be same,

the following sql statement can be used :

SELECT agents.agent_name,customer.cust_name,
customer.cust_city
FROM agents,customer
WHERE agents.working_area=customer.cust_city;

Output

Sql equi join

What is the difference between Equi Join and Inner Join in SQL?

An equijoin is a join with a join condition containing an equality operator. An equijoin returns only the rows that have equivalent values for the specified columns.

An inner join is a join of two or more tables that returns only those rows (compared using a comparison operator) that satisfy the join condition.

Key points to remember

Click on the following to get the slides presentation -

SQL JOINS, slide presentation



<<PreviousNext>>