SQL CHEATSHEET
š Hi, Iām Jean,
Iām the Founder of Exaltitude, a platform built to help software engineers grow, get recognized, and stay relevantāespecially in a rapidly changing tech landscape.
With 20+ years of experience in Silicon Valley, Iāve worked at both startups and giants, including being the 19th engineer at WhatsApp and later leading teams at Meta after the $19B acquisition. Over the years, Iāve interviewed hundreds of engineers and mentored even moreāhelping them land jobs, level up, and thrive.
Iāve created this SQL Cheatsheet to simplify the learning process for you, whether youāre prepping for interviews, working with data, or just getting started. Itās clean, concise, and practicalājust like I wish I had when I was learning.
š If youāre not already connected with me:
Follow me on LinkedIn for career advice and AI news
Subscribe to YouTube for tutorials, explainers, and tech strategy
Check out exaltitude.io for many free guides and resources
Letās build your future, one skill at a time!
Jean Lee
Outline
Definitions
Querying Data
Joining Tables
Grouping & Aggregation
Table & Data Management
Definitions
SQL: Structured Query Language for accessing and manipulating databases.
DDL: Data Definition Language ā create/modify table structures (CREATE, DROP, etc.).
DML: Data Manipulation Language ā manage data (SELECT, INSERT, UPDATE, DELETE).
DCL: Data Control Language ā control access (GRANT, REVOKE).
Database: A collection of data organized for easy access, management, and updating.
Data: Raw facts or information stored in a database, typically in rows and columns.
Table: A collection of data organized in rows and columns.
Row: A single record in a table, representing a data entry.
Column: A field in a table that defines a specific type of data (e.g., name, age).
Primary Key: Uniquely identifies each row in a table.
Foreign Key: A key used to link two tables. It references the primary key in another table.
Schema: Structure of a database (tables, views, relationships, etc.).
Index: Improves query performance on specific columns by speeding up lookups.
View: A virtual table based on a saved SELECT query, often used to simplify complex joins or filters.
Query: A request to retrieve or manipulate data in a database, usually written in SQL.
Querying Data
SELECT
Retrieves specific columns of data from a table.
SELECT name, age FROM users;
Returns the name and age columns from the āusersā table.
WHERE
Filters rows based on a specified condition.
SELECT * FROM orders WHERE status = āshippedā;
Only returns orders where the status is āshippedā.
ORDER BY
Sorts the result set by one or more columns.
SELECT name FROM employees ORDER BY hire_date DESC;
Lists employees sorted by newest hire date first.
AND / OR
Combines multiple conditions in a WHERE clause.
SELECT * FROM products WHERE price > 50 AND stock > 0;
Finds products that are over $50 and in stock.
NULL
Represents missing or undefined values.
SELECT * FROM customers WHERE phone IS NULL;
Returns customers with no phone number listed.
DISTINCT
Removes duplicate values from the result.
SELECT DISTINCT country FROM customers;
Lists each country once, even if repeated in the table.
BETWEEN
Filters results within an inclusive range.
SELECT * FROM sales WHERE amount BETWEEN 100 AND 500;
Finds sales with amounts between 100 and 500.
LIKE
Searches for a pattern in a column using wildcards.
SELECT * FROM users WHERE email LIKE ā%@gmail.comā;
Finds users with Gmail addresses.
IN
Matches a columnās value against a list.
SELECT * FROM employees WHERE department IN (āHRā, āFinanceā);
Returns employees in either HR or Finance.
ALIAS
Renames a column or table for readability.
SELECT name AS employee_name FROM staff;
Renames the output column to āemployee_nameā.


