Skip to main content

    Lesson 1 • Beginner Track

    Introduction to SQL

    By the end of this lesson you'll know exactly what SQL is, what a database, table, row, and column actually are, why SQL runs behind nearly every app you use — and you'll have written your very first SELECT query.

    What You'll Learn

    • What SQL is and the problem it solves
    • What a relational database, table, row, and column are
    • What an RDBMS is (MySQL, PostgreSQL, SQLite, SQL Server)
    • Why SQL matters — it's everywhere, and you learn it once
    • How tables can reference each other, like linked spreadsheets
    • Write and read your first SELECT statement

    1. What Is SQL?

    SQL (Structured Query Language, said "sequel" or "S-Q-L") is the standard language for asking questions of — and making changes to — a database. A database is just an organised store of information; SQL is how you talk to it.

    SQL is a declarative language: you describe what data you want, and the database figures out how to fetch it. That's different from languages like Python or JavaScript, where you spell out every step. It's why a SQL query often reads almost like an English sentence.

    📚 Real-world analogy

    Picture a library with millions of books. You don't walk every aisle yourself — you tell the librarian, "Find me all mystery novels published after 2020, sorted by rating." You describe the result; the librarian does the searching. SQL is that request, and the database engine is the librarian.

    2. Databases, Tables, Rows & Columns

    Almost all SQL databases are relational, which means the data lives in tables. If you've used a spreadsheet, you already understand a table:

    • 🗄️Database — the whole store of data. One database holds many tables (think: one workbook holding many sheets).
    • 📋Table — data laid out in a grid of rows and columns, like a single spreadsheet sheet (e.g. a customers table).
    • ➡️Row (also called a record) — one entry across the grid: a single customer, order, or product.
    • ⬇️Column (also called a field) — one attribute that every row has, such as first_name or city.
    • Query — a request you send to the database, such as "give me every customer in London".

    📊 Real-world analogy

    Think of a database as a set of spreadsheets that can reference each other. A customers sheet and an orders sheet are separate, but an order can point back to the customer who placed it. That "tables linking to other tables" idea is exactly what the relational in relational database means — and it's the superpower a pile of disconnected spreadsheets doesn't have.

    ⚠️ Common mistake

    Don't confuse a database with a table. A database contains tables. Picture it like this: a database = a whole school; a table = one class roster.

    Our Sample Table: customers

    Here's a tiny customers table. Every query in this lesson runs against it. It has 4 rows and 4 columns — find the rows (each customer) and the columns (id, first_name, city, signup_year) before reading on.

    Result:

    idfirst_namecitysignup_year
    1AdaLondon2021
    2BjarneAarhus2023
    3GraceNew York2020
    4LinusHelsinki2022

    3. What's an RDBMS?

    The actual software that stores your tables and runs your SQL is called a relational database management system, or RDBMS. SQL is the language; the RDBMS is the engine that understands it.

    There are several popular ones, and they all speak SQL:

    • 🐬MySQL — extremely common for web apps and WordPress sites.
    • 🐘PostgreSQL — powerful and standards-focused; a favourite for new projects.
    • 📦SQLite — a tiny, file-based database built into phones, browsers, and apps.
    • 🪟SQL Server — Microsoft's enterprise database, common in big companies.

    4. Why SQL Matters

    SQL has been around since the 1970s and it isn't going anywhere — it's the universal language of data. Wherever information is stored, SQL is usually how people get it out:

    🌐 Behind every app

    Web and mobile apps store their data in a database. SQL is how the app reads and writes that data — your social feed, your bank balance, your shopping cart.

    📊 Data analysis

    Analysts, marketers, and product managers pull insights from millions of records in seconds — most of it with plain SQL.

    🤖 Data science & AI

    Before any model is trained, the data has to be gathered and cleaned. SQL is the primary tool for extracting and preparing those datasets.

    💼 Career value

    SQL is one of the most requested skills in job listings, across developers, analysts, and data engineers alike.

    5. A First Taste of SELECT

    Most of SQL boils down to four everyday jobs on your data — often called CRUD: Create (INSERT), Read (SELECT), Update (UPDATE), and Delete (DELETE). You'll meet all four across the course; this lesson focuses on the one you'll use most.

    That command is SELECT — it reads data and hands you back a result, without ever changing the table. Because it only reads, it's completely safe to experiment with. Here it is in its simplest form, asking for every column of every row:

    Your first query — SELECT *

    Return every column and every row from customers.

    Try it Yourself »
    SQL
    -- Your very first SQL query.
    -- SELECT means "show me data"; * means "every column"; FROM names the table.
    SELECT * FROM customers;
    
    -- Read it like a sentence: "Select all columns from the customers table."
    -- The database reads the table and hands back every row it finds.

    Result — all 4 rows:

    idfirst_namecitysignup_year
    1AdaLondon2021
    2BjarneAarhus2023
    3GraceNew York2020
    4LinusHelsinki2022

    The * is a wildcard meaning "all columns" — handy for a quick peek. More often you'll name only the columns you want, separated by commas:

    Pick specific columns

    Ask only for first_name and city.

    Try it Yourself »
    SQL
    -- You rarely want every column. Name just the ones you care about,
    -- separated by commas, in the order you want them shown.
    SELECT first_name, city
    FROM customers;
    
    -- "Show me the first_name and city columns from the customers table."
    -- Same rows, but only the two columns you asked for.

    Result — 4 rows, 2 columns:

    first_namecity
    AdaLondon
    BjarneAarhus
    GraceNew York
    LinusHelsinki

    Your Turn: select everything

    Fill in the blanks to return every column for every row in customers. The expected result is in the comments so you can check yourself.

    🎯 Your Turn: SELECT *

    Replace the ___ blanks to select all columns from customers.

    Try it Yourself »
    SQL
    -- 🎯 YOUR TURN — fill in the two blanks, then copy this into a playground to run.
    -- Goal: return EVERY column for EVERY row in the customers table.
    
    SELECT ___ FROM ___;     -- 👉 blank 1: the wildcard for "all columns"
                             -- 👉 blank 2: the table name (it's "customers")
    
    -- ✅ Expected result: all 4 rows, all 4 columns
    --    (id, first_name, city, signup_year) exactly as shown in the sample table above.

    Your Turn: pick two columns

    Now choose just the first_name and signup_year columns, in that order. Fill in all three blanks.

    🎯 Your Turn: choose columns

    Replace the ___ blanks with the column names and the table name.

    Try it Yourself »
    SQL
    -- 🎯 YOUR TURN — fill in the blanks to choose specific columns.
    -- Goal: list each customer's first_name and signup_year (in that order).
    
    SELECT ___, ___      -- 👉 put the two column names here, separated by a comma
    FROM ___;            -- 👉 the table name again
    
    -- ✅ Expected result: 4 rows, two columns (first_name, signup_year)
    --    Ada | 2021 ,  Bjarne | 2023 ,  Grace | 2020 ,  Linus | 2022

    Common Errors (and the fix)

    • "no such table: customer" — the table name must match exactly. It's customers (plural), not customer. SQL won't guess for you.
    • Forgetting FROM: SELECT first_name; errors — every column query needs a table to read from: SELECT first_name FROM customers;
    • "no such column: firstname" — column names must match exactly too. It's first_name with an underscore, not firstname.
    • Nothing runs / "syntax error": the in-browser editor only edits SQL — it can't execute it. Copy your query into sqliteonline.com to actually run it.
    • Missing semicolon: most tools want a ; to mark the end of a statement, especially when you run several at once.

    📘 Quick Reference — key terms

    TermWhat it means
    DatabaseAn organised store of data; holds many tables
    TableA grid of rows and columns, like a spreadsheet sheet
    RowOne entry in a table (one customer, one order) — also a record
    ColumnOne attribute every row has (first_name, city) — also a field
    QueryA request you send to the database, e.g. a SELECT
    RDBMSThe engine that stores tables and runs SQL (MySQL, PostgreSQL, SQLite, SQL Server)

    Frequently Asked Questions

    Q: Is SQL a programming language like Python?

    Not quite. SQL is a query language built for one job: working with data in databases. It's declarative — you describe the result you want, not the step-by-step instructions. You'll often use it alongside a language like Python or JavaScript.

    Q: Do I need to install a database to follow along?

    No. Read the lesson here, then paste any query into a free online playground such as sqliteonline.com to run it. Every example shows its expected result so you can self-check either way.

    Q: There are several databases (MySQL, PostgreSQL…) — which should I learn?

    Start with the standard SQL taught here; it works in all of them. The differences are small extras you can pick up later. If you must pick one to practise in, SQLite or PostgreSQL are friendly choices.

    Q: Is SQL case-sensitive?

    Keywords like SELECT and FROM are not case-sensitive, but the convention is to write them in UPPERCASE so they stand out. Table and column names can be case-sensitive depending on the database, so match them exactly.

    Mini-Challenge: Your Own SELECT

    No blanks this time — just a brief and the expected result in the comments. Write the query from scratch, then copy it into a playground to confirm it matches.

    🎯 Mini-Challenge

    Select first_name and city from the customers table.

    Try it Yourself »
    SQL
    -- 🎯 MINI-CHALLENGE
    -- Using ONLY what this lesson covered (SELECT, choosing columns, FROM):
    --   1. From the customers table, show just two columns: first_name and city.
    --   2. Keep them in that order (first_name first, then city).
    --
    -- ✅ Expected result: 4 rows, two columns (first_name, city)
    --    Ada | London ,  Bjarne | Aarhus ,  Grace | New York ,  Linus | Helsinki
    
    -- your query here

    🎉 Lesson Complete

    • SQL is the declarative language for asking questions of a database
    • ✅ A relational database stores data in tables of rows and columns
    • ✅ Tables can reference each other — like a set of linked spreadsheets
    • ✅ An RDBMS (MySQL, PostgreSQL, SQLite, SQL Server) is the engine that runs SQL
    • SELECT * FROM table reads every column; naming columns reads just those
    • Next: create your first database and table in Database Basics & Tables

    Sign up for free to track which lessons you've completed and get learning reminders.

    Cookie & Privacy Settings

    We use cookies to improve your experience, analyze traffic, and show personalized ads. You can manage your preferences below.

    By clicking "Accept All", you consent to our use of cookies for analytics and personalized advertising. You can customize your preferences or reject non-essential cookies.

    Privacy PolicyTerms of Service

    Install LearnCodingFast

    Learn faster with the app on your home screen.