Joins

image
image
  • NATURAL JOIN = combines two tables on common columns (based on name and datatype)
    • Natural join VS inner join differ on number of columns returned, read
    • Inner join with USING will be natural join
  • CROSS JOIN = cartesian product of two tables, read.
    • … FROM TABLE1 A, TABLE2 B …
  • LEFT JOIN = returns all records from the left table (table1), and the matching records from the right table (table2)
  • SELF JOIN = each row in a table is joined to itself and every other row in that table.
    • Ex: match customers from the same city, read
  • UNION = concatenate two tables
    • Ex: return the list of all customers and suppliers
SuperMade with Super