3

The most common type of join is: SQL INNER JOIN (simple join). An SQL INNER JOIN return all rows from multiple tables where the join condition is met.

This what W3Schools says about Inner Join. I was reading database management by Korth and one chapter in it was on relational algebra. In that, there was a Natural Join which, in my limited understanding, is the same as Inner Join.

Can someone please tell me if there is a difference between the two or they are different names of referring to the same thing.

An SO User
  • 24,612
  • 35
  • 133
  • 221
  • Duplicate of http://stackoverflow.com/questions/8696383/difference-between-natural-join-and-inner-join/8696402?noredirect=1#comment33678249_8696402. –  Mar 05 '14 at 22:27

2 Answers2

7

A Natural Join is a form of Inner Join where the join is implicitly across all columns of matching names on both sides of the join.

E.g.

Table A
abc int
def int
ghi varchar(20)

Table B
abc int
def int
jkl int

A natural join between tables A and B would be the same as an inner join on columns abc and def.


Inner joins that could not be replaced with a Natural Join:

TableA
   inner join
TableB
   on
       TableA.Column1 = TableB.Column2 --Column names don't match

or

TableA
   inner join
TableB
   on
       TableA.Column1 >= TableB.Column1 --Not equality
Damien_The_Unbeliever
  • 234,701
  • 27
  • 340
  • 448
2

Natural Join and Inner Join are not same commands.
Natural Join joins the tables on the basis of equality of values of common columns without typing the condition in query......while Inner join joins tables on the basis of condition specified in query which can be "=" or ">=" or "<="....

Natural Join :

tab1 NATURAL JOIN tab2;

this will automatically check for equality of values of common columns

Iner Join:

tab1 INNER JOIN tab2 ON (condition);

Moreover, NATURAL JOIN gives common column once in the output of query while INNER JOIN gives common columns of both tables

Dhruvam Gupta
  • 482
  • 5
  • 10