Join 3 Tables
Jump to navigation
Jump to search
=== 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';