What is the difference between cross join and natural join?

0

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 tables but only one copy of each common column.

Cross Join :

Cross Join will produce cross or Cartesian product of two tables if there is no condition specifies. The resulting table will contain all the attributes of both the tables including duplicate or common columns also



NATURAL JOIN

CROSS JOIN

Natural Join joins two tables based on same attribute name and datatypes.

Cross Join will produce cross or cartesian product of two tablesΒ 

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 Cross Join, The resulting table will contain all the attribute of both the tables including duplicate columns also

In Natural Join, If there is no condition specifies then it returns the rows based on the common column

In Cross Join, If there is no condition specifies then it returns all possible pairing of rows from both the tables whether they are matched or unmatched

SYNTAX:

SELECT * FROM table1 NATURAL JOIN table2;

SYNTAX:

SELECT * FROM table1 CROSS JOIN table2;

Sql
asked Apr 14, 2023 at 22:21
Sign in to add a comment

0 Answers

0
πŸ“ No answers yet!

Be the first to answer this interview question.

Your Answer

Sign in to post your answer and help the community.