SQL Tutorial for Beginners: Learn SQL Step by Step

By Softlookup Editorial Team · Updated April 24, 2026 · 15 min read · Free 21-chapter course

New to SQL? You're in the right place. This free tutorial takes you from zero to writing real queries in about 2 hours. You don't need to install anything, you don't need prior programming experience, and every example below is something you can type into a browser-based sandbox right now.

What Is SQL?

SQL (Structured Query Language) is the language you use to talk to databases. When you want to pull the top 10 customers from a database of a million, calculate total sales for last quarter, or update every product that's out of stock — SQL is how you do it.

SQL was created in the 1970s at IBM and has outlived every programming language that tried to replace it. Every major database — MySQL, PostgreSQL, SQL Server, Oracle, SQLite — speaks SQL. Learn it once, and you can work with any of them.

Why Learn SQL in 2026?

Three reasons, in order of how practical they are:

  1. It's on every data job posting. Data analyst, data engineer, business intelligence developer, product analyst, marketing analyst — SQL is the non-negotiable first skill for all of them.
  2. It pays well for the effort. A week of focused learning gets you to "job-ready" for entry-level data roles that start around $55–70k in the US.
  3. It ages well. The SQL you learn today will still work in 2040. The Python library you just learned probably won't.

What You'll Learn in This Tutorial

This is a 21-chapter course covering:

By the end, you'll be able to read any SQL query in the wild, write the queries you need for data analysis or app development, and know which features of each database flavor to watch for.

Prerequisites

None. You don't need to know Python, JavaScript, or any other language. You don't need to understand databases yet — we'll cover that. You just need a browser and about 15 hours of total time spread however works for you.

How to Practice SQL Without Installing Anything

Before you read another chapter, open one of these in a new tab. You'll want to run the queries in this page and the later chapters:

All three are free. Pick one and leave it open in a tab.

A Quick Look at a Database

A database is a collection of tables. A table is just rows and columns — like a spreadsheet, but with rules. Here's a tiny example database we'll use throughout this tutorial.

Table: customers

idnamecitycountrysignup_date
1Alice ChenParisFrance2024-03-15
2Bob MartinezMadridSpain2024-06-22
3Carla RossiRomeItaly2025-01-08
4David KimParisFrance2025-04-30
5Elena PopescuBucharestRomania2025-11-12

Table: orders

idcustomer_idproductamountorder_date
1011Laptop12002024-04-02
1022Headphones892024-07-18
1031Monitor3502025-02-09
1044Keyboard1202025-05-11
1053Laptop14502025-06-25

Two tables, ten rows, five columns each. Every example in this tutorial uses these two tables so you always know what you're looking at.

Your First SQL Query

Here's the simplest useful SQL statement:

SELECT * FROM customers;

Three words. It means "give me every column (*) from the customers table." The result is the entire customers table shown above.

Now let's make it useful — only show names and cities:

SELECT name, city FROM customers;

Result:

namecity
Alice ChenParis
Bob MartinezMadrid
Carla RossiRome
David KimParis
Elena PopescuBucharest
Tip: SQL keywords like SELECT and FROM are traditionally written in uppercase to stand out. SQL itself doesn't care — select and SELECT are identical. Pick a style and stick with it.

Filtering Rows with WHERE

You almost never want all rows. Use WHERE to filter:

SELECT name, city
FROM customers
WHERE country = 'France';

Result:

namecity
Alice ChenParis
David KimParis

You can combine conditions with AND and OR:

SELECT name
FROM customers
WHERE country = 'France' AND signup_date > '2025-01-01';

That returns just David Kim — the only French customer who signed up in 2025.

Sorting Results with ORDER BY

SELECT name, signup_date
FROM customers
ORDER BY signup_date DESC;

DESC means newest first. Leave it off (or write ASC) for oldest first.

Limiting Results

Only want the top 3? Add LIMIT:

SELECT name, signup_date
FROM customers
ORDER BY signup_date DESC
LIMIT 3;
Dialect note: SQL Server uses TOP instead of LIMIT (SELECT TOP 3 ...). Oracle historically uses ROWNUM. PostgreSQL, MySQL, and SQLite all use LIMIT.

Joining Two Tables

Here's where SQL gets powerful. We have customers and orders in separate tables. To see which customer placed each order, we JOIN them:

SELECT customers.name, orders.product, orders.amount
FROM customers
INNER JOIN orders ON customers.id = orders.customer_id;

Result:

nameproductamount
Alice ChenLaptop1200
Bob MartinezHeadphones89
Alice ChenMonitor350
David KimKeyboard120
Carla RossiLaptop1450

The ON clause is where the magic happens — it tells SQL: "match rows from customers and orders where customers.id equals orders.customer_id."

Notice Elena Popescu isn't in the result — she has no orders. INNER JOIN only returns rows that match in both tables. To include customers with no orders, use LEFT JOIN (we'll cover this in Chapter 6).

Aggregating Data

How much total revenue did each customer generate?

SELECT customers.name, SUM(orders.amount) AS total_spent
FROM customers
INNER JOIN orders ON customers.id = orders.customer_id
GROUP BY customers.name
ORDER BY total_spent DESC;

Result:

nametotal_spent
Alice Chen1550
Carla Rossi1450
David Kim120
Bob Martinez89

The GROUP BY is essential — without it, SUM() would add up every row into one total. With it, SQL gives you one sum per customer.

Other useful aggregate functions: COUNT(), AVG(), MIN(), MAX().

Changing Data: INSERT, UPDATE, DELETE

Reading data is only half of SQL. Here's how you change it.

INSERT adds a new row:

INSERT INTO customers (name, city, country, signup_date)
VALUES ('Frank Weber', 'Berlin', 'Germany', '2026-04-24');

UPDATE changes existing rows:

UPDATE customers
SET city = 'Lyon'
WHERE id = 4;

DELETE removes rows:

DELETE FROM customers
WHERE id = 5;
Warning: Always include a WHERE clause with UPDATE and DELETE. Forgetting it updates or deletes every row in the table. Many engineers have a horror story about the day they ran UPDATE users SET password = 'hello' without a WHERE.

Complete Learning Path

Work through these chapters in order. Each builds on the previous one. Estimated time: 30–60 minutes per chapter, 15 hours total.

  1. Chapter 1 — Introduction to SQL
  2. Chapter 2 — The SELECT Statement
  3. Chapter 3 — Expressions, Conditions, and Operators
  4. Chapter 4 — Functions: Molding the Data You Retrieve
  5. Chapter 5 — Clauses in SQL
  6. Chapter 6 — Joining Tables
  7. Chapter 7 — Subqueries: The Embedded SELECT Statement
  8. Chapter 8 — Manipulating Data (INSERT, UPDATE, DELETE)
  9. Chapter 9 — Creating and Maintaining Tables
  10. Chapter 10 — Creating Views and Indexes
  11. Chapter 11 — Controlling Transactions
  12. Chapter 12 — Database Security
  13. Chapter 13 — Advanced SQL Topics
  14. Chapter 14 — Dynamic Uses of SQL
  15. Chapter 15 — Streamlining SQL for Performance
  16. Chapter 16 — Using Views for the Data Dictionary
  17. Chapter 17 — Using SQL to Generate SQL
  18. Chapter 18 — PL/SQL: An Introduction
  19. Chapter 19 — Transact-SQL: An Introduction
  20. Chapter 20 — SQL*Plus
  21. Chapter 21 — Common SQL Mistakes and Fixes
Start Chapter 1: Introduction to SQL →

SQL Cheat Sheet

Keep this nearby while you work. Every common statement you'll use in the first month of learning SQL:

What You WantSQL Statement
Get all data from a tableSELECT * FROM table_name;
Get specific columnsSELECT col1, col2 FROM table_name;
Filter rowsSELECT * FROM t WHERE col = 'value';
Sort resultsSELECT * FROM t ORDER BY col DESC;
Limit resultsSELECT * FROM t LIMIT 10;
Count rowsSELECT COUNT(*) FROM t;
Sum valuesSELECT SUM(col) FROM t;
Group & aggregateSELECT col, COUNT(*) FROM t GROUP BY col;
Join two tablesSELECT * FROM a JOIN b ON a.id = b.a_id;
Insert a rowINSERT INTO t (col) VALUES ('val');
Update rowsUPDATE t SET col = 'new' WHERE id = 1;
Delete rowsDELETE FROM t WHERE id = 1;
Create a tableCREATE TABLE t (id INT, name TEXT);
Drop a tableDROP TABLE t;

Common Beginner Mistakes

These catch almost everyone. Knowing them in advance saves hours.

1. Forgetting WHERE on UPDATE or DELETE

Running DELETE FROM users with no WHERE deletes every user. Always run the SELECT equivalent first to confirm which rows you're about to change, then switch to UPDATE or DELETE.

2. Using = instead of LIKE for partial matches

WHERE name = 'Alice%' looks for the literal string "Alice%". You want WHERE name LIKE 'Alice%' — with LIKE, % is a wildcard.

3. Comparing NULL with = instead of IS NULL

WHERE email = NULL returns no rows ever. Null isn't equal to anything, including itself. Use WHERE email IS NULL.

4. Case sensitivity surprises

In most databases, SQL keywords are case-insensitive but string values are case-sensitive. WHERE country = 'france' won't match 'France'. Use LOWER() or ILIKE (PostgreSQL) for case-insensitive matching.

5. Trying to use WHERE with aggregate functions

WHERE COUNT(*) > 5 fails. For filtering aggregates, use HAVING after GROUP BY: GROUP BY col HAVING COUNT(*) > 5.

Frequently Asked Questions

Is SQL hard to learn for beginners?

No — SQL is one of the easiest programming languages to start with. It reads almost like English (SELECT name FROM customers WHERE city = 'Paris'), there's nothing to install to practice it, and you can run your first useful query within 15 minutes of starting.

How long does it take to learn SQL?

Most beginners can write basic SELECT, WHERE, and ORDER BY queries after 2–3 hours. JOINs and GROUP BY take another few days of practice. Advanced topics like window functions and query optimization take months to master.

Do I need to install anything to learn SQL?

No. You can practice SQL in your browser using free sandboxes like SQLite Online, DB Fiddle, or SQLZoo. For local practice, SQLite is free, requires no setup, and comes pre-installed on macOS and Linux.

What's the difference between SQL and MySQL?

SQL is the language. MySQL is one specific database system that uses SQL. Other databases include PostgreSQL, SQLite, Microsoft SQL Server, and Oracle — they all speak SQL but each has its own dialect with small differences.

Which SQL database should I learn first?

SQLite for learning (zero setup), PostgreSQL for serious work (free, powerful, most in-demand), and Microsoft SQL Server or MySQL if you're targeting specific industry jobs.

Is SQL still worth learning in 2026?

Yes. SQL is still the #1 skill listed in data analyst, data engineer, and backend developer job postings. Despite new tools and AI, SQL remains the universal language for working with relational data — every major database still uses it.

Can I learn SQL without programming experience?

Yes. SQL is declarative — you tell it what you want, not how to get it. That makes it accessible to analysts, marketers, and anyone who works with data without needing to know Python, JavaScript, or any other language first.

How much do SQL developers earn?

Entry-level SQL roles (data analyst) typically start around $55,000–$70,000 in the US. Mid-level SQL-focused roles (data engineer, BI developer) range from $85,000–$130,000. Senior database administrators and architects can earn $140,000+.

Ready to Start?

You now know what SQL is, what you'll learn, and how to practice. You've already seen the six most common query types. Chapter 1 goes deeper on what relational databases actually are and sets you up for everything that follows.

Start Chapter 1: Introduction to SQL →

Last updated: April 24, 2026. This tutorial is free and stays free. No signup, no paywall.