SQL Cheatsheet
The core SQL you use to ask questions of a database, from simple selects to joins and aggregates. Format messy queries with the SQL formatter.
Querying
Retrieve specific columns.
Retrieve all columns.
Unique values only.
Paginate results.
Filtering
Filter rows by a condition.
Match any of a set.
Pattern match on text.
Range match (inclusive).
Match rows with no value.
Sorting & grouping
Sort results, descending.
Group rows for aggregation.
Filter groups (after GROUP BY).
Joins
Rows matching in both tables.
All left rows, matched right or NULL.
All right rows, matched left or NULL.
Aggregates
Number of rows.
Total and average of a column.
Smallest and largest value.
Modifying data
Add a new row.
Change existing rows.
Remove rows (mind the WHERE!).