Free Online Course · Self-paced

SQL Tutorial for Beginners (Hands-On with Real Examples)

Free, complete SQL tutorial - SELECT, INSERT, UPDATE, DELETE, all JOIN types, GROUP BY, aggregate and window functions, constraints, stored procedures, transactions, and date/time/string functions. 85+ runnable lessons covering MySQL, PostgreSQL, SQL Server, and SQLite.

  • 84 parts
  • ~780 min total
  • Beginner to Intermediate
  • Updated May 2026
SQL Tutorial for Beginners (Hands-On with Real Examples)
By Last updated

SQL is the lingua franca of data. From a 12-row product catalogue on a side-project to a 50-billion-row event log at a tech giant, the language you ask questions in is the same: SELECT ... FROM ... WHERE ... GROUP BY. This tutorial takes you from "what is a table?" to window functions and transactions - the same path a working data analyst, backend developer, or SRE walks through in their first six months on the job.

We start with installing a free SQL engine and connecting it to VS Code, then walk through every fundamental query - filtering, joining, aggregating, updating, deleting - before moving on to the things that separate confident SQL writers from struggling ones: every JOIN type with side-by-side diagrams, GROUP BY with HAVING, the five aggregate functions, all four major constraint types, window functions, stored procedures, triggers, and transactions. Each lesson is short, every snippet was tested on MySQL 8, PostgreSQL 14, and SQL Server 2019, and the differences between vendors are called out explicitly where they matter.

Click Start the course to begin with Getting started with SQL, or jump to the topic you need - JOINs, GROUP BY, ORDER BY, Aggregates, and Window Functions and CTEs are the chapters working developers and analysts come back to most often. If you finish this course and want to specialize, the next courses are Python Tutorial (for pairing SQL with application code) and the Pandas Tutorial (for moving from SQL into in-memory data analysis).

What you'll learn

  • Write `SELECT`, `INSERT`, `UPDATE`, and `DELETE` queries with confidence
  • Master every `JOIN` type - INNER, LEFT, RIGHT, FULL OUTER, and self-joins on multiple tables
  • Use `GROUP BY`, `HAVING`, and the five aggregate functions (`COUNT`, `SUM`, `AVG`, `MIN`, `MAX`)
  • Filter with `WHERE`, `BETWEEN`, `IN`, `LIKE`, `EXISTS`, and combine conditions safely
  • Apply constraints (`NOT NULL`, `UNIQUE`, `CHECK`, `FOREIGN KEY`) and pick the right data types
  • Transform data with built-in string, date/time, and numeric functions across vendors
  • Use window functions (`RANK`, `DENSE_RANK`, `ROW_NUMBER`) and `WITH` (CTE) for analytics
  • Write stored procedures, triggers, and transactions that are safe under concurrency

Prerequisites

  • A running SQL engine - MySQL 8+, PostgreSQL 14+, SQL Server 2019+, or SQLite 3 all work
  • A SQL client - DBeaver, MySQL Workbench, pgAdmin, or VS Code with the SQL extension
  • Comfortable on the command line (helpful but not required)

Syllabus

15 chapters · 84 lessons · ~780 min of reading

  1. 1 Getting Started 4 lessons
    1. Part 1 Getting started with SQL 16 min read
    2. Part 2 Connect a free SQL database to VS Code 7 min read
    3. Part 3 Add comments in SQL (-- and /* */) 5 min read
    4. Part 4 Import a .sql file into MySQL 4 min read
  2. 2 Data Types and Tables 10 lessons
    1. Part 5 SQL data types (INT, VARCHAR, DATE, etc.) 11 min read
    2. Part 6 CREATE TABLE statement 8 min read
    3. Part 7 ALTER TABLE and ADD COLUMN 7 min read
    4. Part 8 Add a column with a default value to an existing table 6 min read
    5. Part 9 DROP TABLE 7 min read
    6. Part 10 TRUNCATE TABLE 10 min read
    7. Part 11 Temporary tables (#temp / @table) 13 min read
    8. Part 12 INSERT INTO a temp table from a stored procedure 5 min read
    9. Part 13 Search the database for a column name 4 min read
    10. Part 14 Fix "ambiguous column name" errors 7 min read
  3. 3 SELECT Statement 7 lessons
    1. Part 15 SELECT TOP / LIMIT (first N rows) 8 min read
    2. Part 16 SELECT DISTINCT (remove duplicates) 8 min read
    3. Part 17 COUNT(DISTINCT col) - count unique values 16 min read
    4. Part 18 Select the first row in each group 5 min read
    5. Part 19 Select the row with the max value 8 min read
    6. Part 20 Find duplicate records 5 min read
    7. Part 21 IF / CASE WHEN inside SELECT 9 min read
  4. 4 INSERT, UPDATE, DELETE 9 lessons
    1. Part 22 INSERT INTO ... SELECT 8 min read
    2. Part 23 INSERT multiple rows in one statement 8 min read
    3. Part 24 UPDATE statement 14 min read
    4. Part 25 UPDATE from a SELECT 11 min read
    5. Part 26 UPDATE multiple columns at once 5 min read
    6. Part 27 UPDATE with a JOIN 7 min read
    7. Part 28 DELETE a row 6 min read
    8. Part 29 DELETE with a JOIN 5 min read
    9. Part 30 DELETE duplicate rows 17 min read
  5. 5 Filtering and Conditions 6 lessons
    1. Part 31 IF statement (SQL Server / MySQL) 8 min read
    2. Part 32 CASE WHEN ... THEN ... END 21 min read
    3. Part 33 BETWEEN ... AND ... 8 min read
    4. Part 34 BETWEEN with dates 10 min read
    5. Part 35 EXISTS (and NOT EXISTS) 9 min read
    6. Part 36 CONTAINS (full-text search) 13 min read
  6. 6 Operators 5 lessons
    1. Part 37 IN operator 8 min read
    2. Part 38 NOT IN operator 7 min read
    3. Part 39 NOT EQUAL (!= and <>) 7 min read
    4. Part 40 LIKE / NOT LIKE / wildcards 9 min read
    5. Part 41 UNION and UNION ALL 8 min read
  7. 7 JOINs 8 lessons
    1. Part 42 INNER JOIN 12 min read
    2. Part 43 LEFT JOIN 11 min read
    3. Part 44 LEFT OUTER JOIN 20 min read
    4. Part 45 LEFT JOIN with multiple tables 8 min read
    5. Part 46 RIGHT JOIN 18 min read
    6. Part 47 RIGHT OUTER JOIN 7 min read
    7. Part 48 OUTER JOIN explained 12 min read
    8. Part 49 FULL OUTER JOIN 8 min read
  8. 8 GROUP BY, ORDER BY, Aggregates 5 lessons
    1. Part 50 GROUP BY statement 8 min read
    2. Part 51 GROUP BY multiple columns 13 min read
    3. Part 52 ORDER BY 11 min read
    4. Part 53 LIMIT / OFFSET (pagination) 7 min read
    5. Part 54 COUNT, SUM, AVG, MIN, MAX 9 min read
  9. 9 Constraints 4 lessons
    1. Part 55 NOT NULL constraint 6 min read
    2. Part 56 CHECK, UNIQUE, and other domain constraints 8 min read
    3. Part 57 DROP CONSTRAINT 5 min read
    4. Part 58 FOREIGN KEY constraint 8 min read
  10. 10 String Functions 7 lessons
    1. Part 59 String concatenation (+, CONCAT, ||) 9 min read
    2. Part 60 CONCAT() function 8 min read
    3. Part 61 SUBSTRING() 10 min read
    4. Part 62 REPLACE() 8 min read
    5. Part 63 Remove characters from a string 10 min read
    6. Part 64 Combine rows into one string (STRING_AGG / GROUP_CONCAT) 6 min read
    7. Part 65 Escape single quotes in SQL 4 min read
  11. 11 Date and Time Functions 5 lessons
    1. Part 66 SQL date format 10 min read
    2. Part 67 SQL date functions 13 min read
    3. Part 68 SQL time functions 18 min read
    4. Part 69 GETDATE() - date only (no time) 8 min read
    5. Part 70 DATEADD() function 8 min read
  12. 12 Numeric and NULL-handling Functions 5 lessons
    1. Part 71 FLOOR() function 3 min read
    2. Part 72 ROUNDUP / round numbers in SQL 8 min read
    3. Part 73 COALESCE() function 8 min read
    4. Part 74 ISNULL() function 8 min read
    5. Part 75 SQL functions - overview 18 min read
  13. 13 Window Functions and CTEs 3 lessons
    1. Part 76 RANK() function 10 min read
    2. Part 77 RANK vs DENSE_RANK vs ROW_NUMBER 12 min read
    3. Part 78 WITH clause (Common Table Expressions) 9 min read
  14. 14 Stored Procedures and Triggers 2 lessons
    1. Part 79 Stored procedures - examples 9 min read
    2. Part 80 Triggers in SQL 15 min read
  15. 15 Transactions and Advanced 4 lessons
    1. Part 81 SQL transactions explained (ACID) 7 min read
    2. Part 82 Mapping cardinality (1:1, 1:N, N:M) 11 min read
    3. Part 83 Build a related-tags search in MySQL 9 min read
    4. Part 84 Send an email at a specific time (SSRS) 12 min read
Deepak Prasad

R&D Engineer

Founder of GoLinuxCloud with over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels across development, DevOps, …

  • Red Hat Certified System Administrator in Red Hat OpenStack
  • Certified Kubernetes Application Developer (CKAD)
  • Red Hat Certified Specialist in Ansible Automation
  • Go (programming language)
  • Python (programming language)
  • DevOps
  • Computer Security