π₯ Learn it step-by-step on YouTube β Watch the Full MySQL Playlist
Subscribe on YouTube for the complete video walkthrough of every topic below, and give this repo a β so more learners can find it. New lessons drop regularly β hit the bell so you never miss one.
This is a structured, beginner-to-advanced MySQL reference built to pair with the video course. Every guide is written as a standalone lesson with clear explanations, copy-paste-ready SQL, and worked examples against a single, consistent sample database β so concepts build naturally from one part to the next.
Whether you're preparing for an interview, leveling up at work, or just starting out, work through the parts in order or jump straight to the topic you need.
- Set up the sample database β start with Part 0: Sample Database and run the schema + seed data in your MySQL instance.
- Follow along with the video β each guide maps to a lesson in the YouTube playlist.
- Practice β every query in these docs runs against the sample database, so you can experiment as you learn.
# Clone the repo
git clone https://github.com/vivekpandey76/Mysql-course.git
cd Mysql-course
#
A488
Load the sample database into MySQL, then start with docs/00-sample-database.md| # | Topic | Guide |
|---|---|---|
| 0 | Sample Database (schema & seed data) | Sample Database |
| 1 | Filtering Data (WHERE, operators, patterns) |
Filtering Data |
| 2 | Aggregate Functions, GROUP BY & HAVING |
Aggregate Functions & GROUP BY |
| 3 | JOINs (INNER, LEFT, RIGHT, SELF) | Joins |
| 4 | Subqueries | Subqueries |
| 5 | Window Functions | Window Functions |
| 6 | Common Table Expressions (CTEs) | Common Table Expressions |
| 7 | String, Date & CASE Functions |
String, Date & CASE Functions |
| 8 | Views (virtual tables) | Views |
| 9 | Stored Procedures | Stored Procedures |
| 10 | Triggers (automatic INSERT/UPDATE/DELETE actions) |
Triggers |
| 11 | UNION & UNION ALL (stacking result sets) |
UNION & UNION ALL |
| 12 | Recursive CTEs (hierarchies & sequence generation) | Recursive CTE |
| 13 | Indexes (single, composite, unique, prefix & EXPLAIN) |
Indexes |
Real-world SQL problems with datasets, expected output, and fully explained solutions β great for interview prep and self-testing.
| Set | Focus | Link |
|---|---|---|
| 1 | Anti-joins, delivery times, running balances, distinct users, cancellation rates | Problem Set 1 |
| 2 | Self-joins & interval overlaps, top-N per group, HAVING, LEAD(), conditional aggregation |
Problem Set 2 |
| 3 | Screening-round classics: Nth-highest salary, find & delete duplicates, manager/dept comparisons, month-over-month growth | Problem Set 3 |
| 4 | Multi-table joins, median (overall & per-group), gaps-and-islands streaks (2 methods), self-UNION win-percentage |
Problem Set 4 |
| 5 | String parsing with SUBSTRING_INDEX, longest win streak, pivot & unpivot reshaping, first/last order per customer |
Problem Set 5 |
| 6 | Consecutive-day orders, "bought all products", missing IDs, NOT EXISTS + theory: GROUP BY rules, DELETE/TRUNCATE/DROP, IFNULL vs COALESCE |
Problem Set 6 |
Full walkthroughs of the complete LeetCode SQL 50 study plan β all 50 problems, the fastest way to get interview-ready. Each problem includes the original LeetCode link, the schema and sample data, real verified output, a "How to approach it" breakdown, and the trade-offs behind the solution.
| Set | Problems | Focus | Link |
|---|---|---|---|
| 1 | 1β10 | WHERE logic, NULL traps, INNER vs LEFT JOIN, anti-joins, LAG(), self-joins |
Set 1 β Select & Basic Joins |
| 2 | 11β20 | CROSS JOIN scaffolding, COUNT(*) vs COUNT(col), HAVING, conditional aggregation, rates & percentages, range joins |
Set 2 β Joins & Aggregation |
| 3 | 21β30 | First-row-per-group with ROW_NUMBER(), DENSE_RANK() on ties, LEAD() retention, COUNT(DISTINCT), relational division, inclusive date windows |
Set 3 β Window Functions & First-Row Logic |
| 4 | 31β40 | Window frames (ROWS vs RANGE), running totals, 7-day moving averages, LEAD(col, n), UNION ALL for zero-count buckets, anti-joins, CASE branching |
Set 4 β Advanced Windows & Conditional Logic |
| 5 | 41β50 | String functions, word-boundary LIKE, REGEXP & case-sensitivity, GROUP_CONCAT, DELETE from a self-referenced table, top-N per group with DENSE_RANK() |
Set 5 β Strings, Regex & Set Operations |
Patterns the SQL 50 skips or only skims β the ones that actually come up in analytics and data-engineering interviews. Custom datasets, same format: schema, real verified output, approach, solution, and the failure modes to avoid.
| Set | Focus | Link |
|---|---|---|
| 1 | Rolling sums: aggregate-then-window, PARTITION BY frames, ROWS vs RANGE, recursive date spines for gappy time series |
Bonus Set 1 β The Rolling Sum Pattern |
mysql/
βββ docs/ # Lesson guides (start with 00, follow in order)
β βββ 00-sample-database.md
β βββ 01-filtering-data.md
β βββ 02-aggregate-functions-and-group-by.md
β βββ 03-joins.md
β βββ 04-subqueries.md
β βββ 05-window-functions.md
β βββ 06-common-table-expressions.md
β βββ 07-string-date-and-case-functions.md
β βββ 08-views.md
β βββ 09-stored-procedures.md
β βββ 10-triggers.md
β βββ 11-union-and-union-all.md
β βββ 12-recursive-cte.md
β βββ 13-indexes.md
βββ interview-questions/ # Practice problem sets with solutions
β βββ problem-set-01.md
β βββ problem-set-02.md
β βββ problem-set-03.md
β βββ problem-set-04.md
β βββ problem-set-05.md
β βββ problem-set-06.md
βββ leetcode-problems/ # LeetCode SQL 50 walkthroughs
β βββ set-01-easy-basics.md
β βββ set-02-joins-and-aggregation.md
β βββ set-03-window-functions-and-first-rows.md
β βββ set-04-advanced-windows-and-conditional-logic.md
β βββ set-05-strings-regex-and-set-operations.md
βββ bonus-problems/ # Patterns the SQL 50 doesn't cover
β βββ set-01-rolling-sum-pattern.md
βββ assets/ # Diagrams & images
β βββ Indexing.png
β βββ joins.png
βββ LICENSE
βββ README.md
- Beginners learning SQL for the first time
- Developers & analysts brushing up on intermediate/advanced querying
- Interview candidates revising joins, subqueries, window functions, and CTEs
- LeetCode grinders who want the reasoning behind each solution, not just an accepted answer
Found a typo, a bug in a query, or have a clearer example? Contributions are welcome β open an issue or submit a pull request.
Released under the MIT License. Free to use, share, and learn from β attribution appreciated.
If this helped you, please β the repo and subscribe on YouTube. It genuinely helps! π