Introduction
SQL (Structured Query Language) is the standard language for storing, retrieving, and managing data in relational databases, letting you ask questions of your data and get back exactly the rows and columns you need.
Learn Python, JavaScript, Java and more with free interactive lessons, real projects and AI-powered help. Beginner-friendly.
Part of the free SQL course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
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.
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.
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.
Almost all SQL databases are relational , which means the data lives in tables . If you've used a spreadsheet, you already understand a table:
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.
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.
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.
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:
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.
Most of SQL boils down to four everyday jobs on your data — often called CRUD : C reate ( INSERT ), R ead ( SELECT ), U pdate ( UPDATE ), and D elete ( 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:
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:
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.
Now choose just the first_name and signup_year columns, in that order. Fill in all three blanks.
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.
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.
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.
Practice quiz
What does SQL stand for?
- Structured Query Language
- Simple Question Language
- Sequential Query Logic
- Standard Quoting Layer
Answer: Structured Query Language. SQL stands for Structured Query Language, the standard language for working with relational databases.
In a relational database, what is a 'table'?
- A single value in a cell
- A grid of rows and columns, like a spreadsheet sheet
- The whole database file
- A request sent to the database
Answer: A grid of rows and columns, like a spreadsheet sheet. A table lays data out in a grid of rows and columns, much like a single spreadsheet sheet.
Which term describes one entry (one customer or order) in a table?
- A column
- A query
- A row (record)
- A database
Answer: A row (record). A row, also called a record, is one entry across the grid of a table.
What does SELECT * FROM customers; return?
- Only the first column
- Every column for every row in customers
- The number of rows
- Only the customer named Ann
Answer: Every column for every row in customers. The * wildcard means 'all columns', so it returns every column for every row.
Which SQL command reads data without changing the table?
- DELETE
- UPDATE
- SELECT
- INSERT
Answer: SELECT. SELECT only reads data and returns a result; it never modifies the table.
What does an RDBMS refer to?
- A type of SQL keyword
- The engine that stores tables and runs SQL (e.g. MySQL, PostgreSQL)
- A single table of data
- A backup file
Answer: The engine that stores tables and runs SQL (e.g. MySQL, PostgreSQL). An RDBMS (relational database management system) is the software that stores tables and runs SQL.
To return only the first_name and city columns, which query is correct?
- SELECT first_name, city FROM customers;
- SELECT customers FROM first_name, city;
- FROM customers SELECT first_name, city;
- SELECT first_name AND city FROM customers;
Answer: SELECT first_name, city FROM customers;. You name the columns after SELECT, separated by commas, then name the table after FROM.
What is the relationship between a database and a table?
- A table contains many databases
- They are the same thing
- A database contains many tables
- A database is a single row
Answer: A database contains many tables. A database is the whole store of data and contains many tables.
Why is SQL described as a 'declarative' language?
- You describe what data you want, not the step-by-step how
- You must spell out every loop and step
- It only works with one database
- It cannot read data
Answer: You describe what data you want, not the step-by-step how. In SQL you describe the result you want and the engine figures out how to fetch it.
Are SQL keywords like SELECT and FROM case-sensitive in standard SQL?
- Yes, they must be lowercase
- Yes, they must be UPPERCASE
- No, but UPPERCASE is the convention
- Only FROM is case-sensitive
Answer: No, but UPPERCASE is the convention. Keywords are not case-sensitive, but the convention is to write them in UPPERCASE so they stand out.