Equijoin or inner join, Natural join, Non-equijoin, Outer join, Self join are the different types of joins used in SQL query.
The NATURAL JOIN is used to join two or more tables and return records that has match on the other table. You can also achieve the same using an equijoin but the query is quite long, unlike using natural join, eliminates the conditions.
Let's try to compare the natural join and the equijoin. Below are the syntax.
SYNTAX SQL EQUIJOIN
select * from table1, table2 where table1.column_name=table2.column_name;SYNTAX SQL NATURAL JOIN
select * from table1 natural join table2;Table:
![]() |
STUDENT |
![]() |
GRADE |
Using the natural join, the query will automatically look for the common column on both tables, so make sure that there is only one (1) common attribute to avoid wrong results.
Query Natural Join
select * from student natural join grade;
Query Equijoin
select * from student,grade where student.stud_id=grade.stud_id;
No comments:
Post a Comment