Skip to main content

SQL Quick Reference

Databases

SQL Quick Reference

# SQL Quick Reference

Core statements for relational databases.

Querying

sql
12345
SELECT column1, column2
FROM table
WHERE condition
ORDER BY column1 DESC
LIMIT 10;
ClausePurpose
SELECTChoose columns
WHEREFilter rows
GROUP BYAggregate rows
HAVINGFilter aggregated groups
ORDER BYSort results
LIMITCap row count

Joins

JoinReturns
INNER JOINRows matching in both tables
LEFT JOINAll left rows + matches
RIGHT JOINAll right rows + matches
FULL JOINAll rows from both sides

Modifying data

sql
123
INSERT INTO users (name, email) VALUES ('Ada', 'ada@example.com');
UPDATE users SET name = 'Ada L.' WHERE id = 1;
DELETE FROM users WHERE id = 1;
← All cheat sheets