KnowledgeBoat Logo
|

Informatics Practices

How is a cross join different from natural join ? Give example.

SQL Joins & Grouping

1 Like

Answer

A cross join is a very basic type of join that simply pairs every row from one table with every row from another table. On the other hand, a natural join is a join where only one of the identical columns from the joined tables exists.

1. CROSS JOIN Example:

SELECT *
FROM students
CROSS JOIN subjects;

This CROSS JOIN will pair every row from the students table with every row from the subjects table, resulting in a Cartesian product of the two tables.

2. NATURAL JOIN Example:

SELECT *
FROM students
NATURAL JOIN subjects;

This NATURAL JOIN will automatically match the common columns and return rows where the values match.

Answered By

2 Likes


Related Questions