Difference between revisions of "Join 3 Tables"
Jump to navigation
Jump to search
Line 14: | Line 14: | ||
INNER JOIN customer D | INNER JOIN customer D | ||
ON A.customer_id = D.customer_id; | ON A.customer_id = D.customer_id; | ||
=== Adding a Filter === | |||
SELECT A.sales_date, A.order_id, A.product_id, B.product_name, C.job_title, D.first_name, D.last_name | |||
FROM sales A INNER JOIN product B | |||
ON A.product_id = B.product_id | |||
LEFT OUTER JOIN salesperson C | |||
ON A.salesperson_id = C.salesperson_id | |||
INNER JOIN customer D | |||
ON A.customer_id = D.customer_id | |||
WHERE C.JOB_TITLE = 'East Manager'; | |||
[[#Select Command|Back To Top]]-[[Main_Page| Home]] - [[Oracle_SQL|Category]] | [[#Select Command|Back To Top]]-[[Main_Page| Home]] - [[Oracle_SQL|Category]] |
Revision as of 20:03, 1 November 2017
=== Join 3 Tables ===
SELECT A.sales_date, A.order_id, A.product_id, B.product_name, C.job_title
FROM sales A INNER JOIN product B ON A.product_id = B.product_id LEFT OUTER JOIN salesperson C ON A.salesperson_id = C.salesperson_id;
Join 4 Tables
SELECT A.sales_date, A.order_id, A.product_id, B.product_name, C.job_title, D.first_name, D.last_name FROM sales A INNER JOIN product B ON A.product_id = B.product_id LEFT OUTER JOIN salesperson C ON A.salesperson_id = C.salesperson_id INNER JOIN customer D ON A.customer_id = D.customer_id;
Adding a Filter
SELECT A.sales_date, A.order_id, A.product_id, B.product_name, C.job_title, D.first_name, D.last_name FROM sales A INNER JOIN product B ON A.product_id = B.product_id LEFT OUTER JOIN salesperson C ON A.salesperson_id = C.salesperson_id INNER JOIN customer D ON A.customer_id = D.customer_id WHERE C.JOB_TITLE = 'East Manager';