54

Can you tell me if inner join and equi-join are the same or not ?

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
user578816
  • 677
  • 1
  • 6
  • 6

6 Answers6

49

An 'inner join' is not the same as an 'equi-join' in general terms.

'equi-join' means joining tables using the equality operator or equivalent. I would still call an outer join an 'equi-join' if it only uses equality (others may disagree).

'inner join' is opposed to 'outer join' and determines how to join two sets when there is no matching value.

Pacerier
  • 86,231
  • 106
  • 366
  • 634
23

Simply put: an equi-join is a possible type of inner-joins

For a more in-depth explanation:

An inner-join is a join that returns only rows from joined tables where a certain condition is met. This condition may be of equality, which means we would have an equi-join; if the condition is not that of equality - which may be a non-equality, greater than, lesser than, between, etc. - we have a nonequi-join, called more precisely theta-join.

If we do not want such conditions to be necessarily met, we can have outer joins (all rows from all tables returned), left join (all rows from left table returned, only matching for right table), right join (all rows from right table returned, only matching for left table).

Luca Tampellini
  • 1,759
  • 17
  • 23
16

The answer is NO.

An equi-join is used to match two columns from two tables using explicit operator =:

Example:

select *
  from table T1, table2 T2
  where T1.column_name1 = T2.column_name2

An inner join is used to get the cross product between two tables, combining all records from both tables. To get the right result you can use a equi-join or one natural join (column names between tables must be the same)

Using equi-join (explicit and implicit)

select *
  from table T1 INNER JOIN table2 T2
  on T1.column_name = T2.column_name

select *
  from table T1, table2 T2
  where T1.column_name = T2.column_name

Or Using natural join

select *
  from table T1 NATURAL JOIN table2 T2
Asclepius
  • 57,944
  • 17
  • 167
  • 143
Osy
  • 1,613
  • 5
  • 21
  • 35
13

The answer is No,here is the short and simple for readers.

Inner join can have equality (=) and other operators (like <,>,<>) in the join condition.

Equi join only have equality (=) operator in the join condition.

Equi join can be an Inner join,Left Outer join, Right Outer join

Shumi Gupta
  • 1,505
  • 2
  • 19
  • 28
1

If there has to made out a difference then ,I think here it is .I tested it with DB2. In 'equi join'.you have to select the comparing column of the table being joined , in inner join it is not compulsory you do that . Example :-

Select k.id,k.name FROM customer k
inner join  dealer on(
k.id =dealer.id
)

here the resulted rows are only two columns rows

id    name

But I think in equi join you have to select the columns of other table too

Select k.id,k.name,d.id FROM customer k,dealer d
where
k.id =d.id

and this will result in rows with three columns , there is no way you cannot have the unwanted compared column of dealer here(even if you don't want it) , the rows will look like

 id(from customer) name(from Customer) id(from dealer)

May be this is not true for your question.But it might be one of the major difference.

Abhishek Bhandari
  • 613
  • 1
  • 5
  • 16
-2

The answer is YES, But as a resultset. So here is an example.

Consider three tables:

orders(ord_no, purch_amt, ord_date, customer_id, salesman_id)

customer(customer_id,cust_name, city, grade, salesman_id)

salesman(salesman_id, name, city, commission)

Now if I have a query like this:

Find the details of an order.

Using INNER JOIN:

SELECT * FROM orders a INNER JOIN customer b ON a.customer_id=b.customer_id 
INNER JOIN salesman c ON a.salesman_id=c.salesman_id;

Using EQUI JOIN:

SELECT * FROM orders a, customer b,salesman c where 
a.customer_id=b.customer_id and a.salesman_id=c.salesman_id;

Execute both queries. You will get the same output.

Coming to your question There is no difference in output of equijoin and inner join. But there might be a difference in inner executions of both the types.

Heli Shah
  • 783
  • 1
  • 8
  • 11
  • 1
    This is not correct. One uses the ANSI 92 JOIN syntax (`FROM a JOIN b ON a.x = b.y`). The other uses the non-ANSI syntax (`FROM a, b WHERE a.x = b.y`). But both join on `a.x = b.y`, which makes them equijoins *because they use the equals sign*. A non-equijoin uses an operator other than the equal sign. That's all it means. Non-equijoin examples: `FROM a JOIN B ON a.x <> b.y` (joins on inequality), `FROM a JOIN b ON a.x BETWEEN b.y AND b.z` (joins on a range). – Ed Gibbs Jul 20 '19 at 03:34