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.

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

R&D Engineer

Founder of GoLinuxCloud with more than 15 years 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, networking, and security, delivering robust and efficient solutions for diverse projects.

  • Go (programming language)
  • Python (programming language)
  • DevOps
  • Computer Security
  • Cloud Computing
  • Kubernetes
  • Linux
  • Ansible (software)