Natural Joins

•Natural Joins clause is based on all columns in the two tables that have the same name and same data type.
•It selects rows from two tables that have equal values in all matched columns
•If the columns have the same names but different data type, an error will appear.

Select department_id, department_name, location_id, city
From departments
Natural join locations;



The locations table is joined with the departments table by location_id column, which is the only column of the same name in both tables.


Using WHERE clause

Select department_id, department_name, location_id, city
From departments
Natural join locations
Where department_id in (20, 50);







0 comments:

Post a Comment