Prerequisite – Join (Inner, Left, Right and Full Joins)
1. Natural Join :
Natural Join joins two tables based on same attribute name and datatypes. The resulting table will contain all the attributes of both the table but keep only one copy of each common column.
Consider the two tables given below:
Consider the given query
SELECT * FROM Student S NATURAL JOIN Marks M;
2. Inner Join :
Inner Join joins two table on the basis of the column which is explicitly specified in the ON clause. The resulting table will contain all the attributes from both the tables including common column also.
Consider the above two tables and the query is given below:
SELECT * FROM student S INNER JOIN Marks M ON S.Roll_No = M.Roll_No;
Difference between Natural JOIN and INNER JOIN in SQL :
|SR.NO.||NATURAL JOIN||INNER JOIN|
|1.||Natural Join joins two tables based on same attribute name and datatypes.||Inner Join joins two table on the basis of the column which is explicitly specified in the ON clause.|
|2.||In Natural Join, The resulting table will contain all the attributes of both the tables but keep only one copy of each common column||In Inner Join, The resulting table will contain all the attribute of both the tables including duplicate columns also|
|3.||In Natural Join, If there is no condition specifies then it returns the rows based on the common column||In Inner Join, only those records will return which exists in both the tables|
FROM table1 NATURAL JOIN table2;
FROM table1 INNER JOIN table2 ON table1.Column_Name = table2.Column_Name;
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Difference between Inner Join and Outer Join in SQL
- Full join and Inner join in MS SQL Server
- Difference between Natural join and Cross join in SQL
- SQL | Join (Cartesian Join & Self Join)
- SQL | Join (Inner, Left, Right and Full Joins)
- Left join and Right join in MS SQL Server
- Self Join and Cross Join in MS SQL Server
- SQL | EQUI Join and NON EQUI JOIN
- Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
- Difference between Nested Loop Join and Hash Join
- Difference between Nested Loop join and Sort Merge Join
- Difference between Hash Join and Sort Merge Join
- Difference between JOIN and UNION in SQL
- Difference between Anonymous Inner Class and Lambda Expression
- SQL | Difference between functions and stored procedures in PL/SQL
- Difference between T-SQL and PL-SQL
- Difference between SQL and T-SQL
- SQL Join vs Subquery
- SQL | UPDATE with JOIN
- Difference between Left, Right and Full Outer Join
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.