Difference between revisions of "Natural Join"
Jump to navigation
Jump to search
(Created page with "A natural join is based on all columns in two tables that have the same name and selects rows from the two tables that have equal values in all matched columns SELECT first_...") |
|||
Line 3: | Line 3: | ||
FROM employees NATURAL JOIN jobs | FROM employees NATURAL JOIN jobs | ||
WHERE department_id > 80 | WHERE department_id > 80 | ||
SELECT sales_date, order_id, product_id | |||
FROM sales NATURAL JOIN product; | |||
This join will return columns from the employees table and their job_title from the jobs table based on the common column job_id | This join will return columns from the employees table and their job_title from the jobs table based on the common column job_id | ||
[[#Select Command|Back To Top]]-[[Main_Page| Home]] - [[Oracle_SQL|Category]] | [[#Select Command|Back To Top]]-[[Main_Page| Home]] - [[Oracle_SQL|Category]] |
Latest revision as of 19:28, 1 November 2017
A natural join is based on all columns in two tables that have the same name and selects rows from the two tables that have equal values in all matched columns
SELECT first_name, last_name, job_id FROM employees NATURAL JOIN jobs WHERE department_id > 80
SELECT sales_date, order_id, product_id FROM sales NATURAL JOIN product;
This join will return columns from the employees table and their job_title from the jobs table based on the common column job_id