Learn SQL - Multiple Tables Cheatsheet - Codecademy
Learn SQL - Multiple Tables Cheatsheet - Codecademy
Multiple Tables
Outer Join
An outer join will combine rows from different tables
even if the join condition is not met. In a LEFT JOIN , SELECT column_name(s)
every row in the left table is returned in the result set, FROM table1
and if the join condition is not met, then NULL values
ON table1.column_name
= table2.column_name;
WITH Clause
The WITH clause stores the result of a query in a
temporary table ( temporary_movies ) using an alias. WITH temporary_movies AS (
SELECT *
FROM temporary_movies
UNION Clause
The UNION clause is used to combine results that
appear from multiple SELECT statements and filter SELECT name
SELECT name
“Hermione”, and a last_names table with a column
FROM last_names
name containing rows of data “James”, “Hermione”
Primary Key
A primary key column in a SQL table is used to uniquely
identify each record in that table. A primary key cannot
be NULL . In the example, customer_id is the
primary key. The same value cannot re-occur in a
primary key column. Primary keys are often used in
JOIN operations.
Inner Join
The JOIN clause allows for the return of results from
more than one table by joining them together with SELECT *
JOIN authors
default JOIN and it will only return results matching