NATURAL
NATURAL is a keyword in SQL used in JOIN operations. It automatically matches the columns between two tables based on the column names and provides a joined table. This type of join doesn't require explicit specification of the columns on which to join. It is important that the corresponding columns in both tables have the same name for a NATURAL JOIN to happen, otherwise, it will result in an error.
Example
Output
Explanation
The SQL command above executes a natural join between table1
and table2
. In a natural join, only the rows with common values in both tables are returned. In our output, columns ID
and Name
are the common fields in both tables, so only the rows with these values are displayed.
Example
Output
Explanation
The NATURAL JOIN
clause is used to combine rows from two tables (table1 and table2) based on the common columns between them. In this case, the common column is ‘id’. So, the rows with the same ‘id’ values in both tables will be combined and displayed in the result.
Example
Output
Explanation
The NATURAL JOIN keyword in Oracle is used to perform a join that returns rows with matching values in both tables. In the above example, the NATURAL JOIN keyword is used to return all rows from Employees and Departments where there is a match based on column names.
Example
Output
Explanation
In the example, customers and orders tables are joined with NATURAL JOIN. NATURAL JOIN automatically fetches the common column (in this case, the ID column) from both tables and merges them based on the common values. Hence, when selected, it displays the record of John who has made an order, combining data from both tables.