Monday, March 2, 2020

Right Joins

-- OUR FIRST RIGHT JOIN (seems the same as a left join?)
SELECT * FROM customers
RIGHT JOIN orders
    ON customers.id = orders.customer_id;
-- ALTERING OUR SCHEMA to allow for a better example (optional)
-- INSERTING NEW DATA (no longer bound by foreign key constraint)

Left Joins

-- Getting Fancier (Inner Joins Still)
-- LEFT JOINS

Inner Joins

-- IMPLICIT INNER JOIN
-- IMPLICIT INNER JOIN
    
-- EXPLICIT INNER JOINS
-- ARBITRARY JOIN - meaningless, but still possible 

Cross Joins

-- Finding Orders Placed By George: 2 Step Process
-- Finding Orders Placed By George: Using a subquery
-- Cross Join Craziness
SELECT * FROM customers, orders; 

Working With Foreign Keys

-- Creating the customers and orders tables
-- Inserting some customers and orders
       
-- This INSERT fails because of our fk constraint.  No user with id: 98

Right Joins

-- OUR FIRST RIGHT JOIN (seems the same as a left join?) SELECT * FROM customers RIGHT JOIN orders     ON customers.id = orders.custom...