SQL / MySQL Tutorial & Reference
Tables, queries, joins, indexes, foreign keys, CTEs, and normalization.
MySQL 8 Learning Path
Follow the SQL / MySQL Curriculum
Read the guides in order from fundamentals to production patterns, or jump to your current skill level.
Showing closest & fuzzy matches for your search.
CREATE DATABASE and Character Set utf8mb4
How do I create a MySQL database that stores Unicode correctly?
CREATE TABLE with Keys, NOT NULL, UNIQUE, and Defaults
How do I create a table with the right data types and constraints?
ALTER TABLE to Add, Modify, and Index a Column
How do I add a column to a table that already has rows?
INSERT and UPDATE Rows with an Explicit WHERE
How do I insert a user and update that same row safely?
DELETE a Single Row with WHERE
How do I delete one row without emptying the table?
SELECT, WHERE, and Comparison Predicates
How do I read specific rows from a MySQL table?
ORDER BY with LIMIT and OFFSET Pagination
How do I page through sorted SQL results?
COUNT, SUM, AVG, GROUP BY, and HAVING
How do I total and filter groups in SQL?
INNER JOIN Across Users, Courses, and Enrollments
How do I combine matching rows from related tables?
LEFT JOIN to Keep Rows with No Match
How do I list every user even when they have no enrollment?
Indexes, Composite Indexes, and EXPLAIN
How do I index a WHERE/ORDER BY so MySQL does not scan the whole table?
Foreign Keys, ON DELETE CASCADE, and ON DELETE SET NULL
How do I stop orphan enrollment rows?
Subqueries in WHERE and in the SELECT List
How do I filter rows using a nested SELECT?
Common Table Expressions with WITH
How do I name a subquery so a report is readable?
Database Normalization: 1NF, 2NF, and 3NF
How do I split repeating course lists out of a user row?
SQL Transactions: START TRANSACTION, COMMIT, ROLLBACK
How do I make two writes succeed or fail together?
CASE Expressions in SELECT
How do I turn a status code into a label in SQL?
UNION of Two Result Sets
How do I stack two SELECT results in one list?
CREATE VIEW for a Roster
How do I save a SELECT as a view?
ROW_NUMBER and SUM Over a Window
How do I rank rows without collapsing them with GROUP BY?
INSERT ... ON DUPLICATE KEY UPDATE
How do I insert a row or update it when the unique key exists?
CHECK Constraints
How do I reject a seat count outside 1 to 40 in the table itself?
MySQL Date Functions
How do I filter rows from the last seven days?
SQL EXISTS for a Membership Test
How do I find lessons that have at least one confirmed seat?
COALESCE and NULLIF
How do I show a fallback when a column is null?
SQL CAST and CONVERT
How do I compare a numeric string column as a number?
SELECT DISTINCT
How do I list each track once?
TRUNCATE versus DELETE
When should I empty a table with TRUNCATE instead of DELETE?
SQL BETWEEN and IN
How do I filter lessons by a seat range or a list of tracks?
MySQL JSON Extract
How do I read a field inside a JSON column?
SQL INTERSECT
How do I find users who both teach and enroll?
SQL LIKE and Escaped Wildcards
How do I search lesson titles without treating a percent sign as a wildcard?
CHAR_LENGTH and LENGTH
How do I measure a title in characters instead of bytes?
LIKE search pattern
How do I search text with a keyword?
WHERE with AND / OR
How do I combine filters in SQL?
COUNT with GROUP BY
How do I count rows per category?
Basic transaction
How do I commit or roll back multiple writes?
No guides matched that search.
Try a shorter keyword, a synonym (like js or db), or remove a filter.