Learn SQL
-- fundamentals.intro

What is SQL?

The standard language for talking to relational databases

--concept

SQL (Structured Query Language) is the programming language you use to store, find, change and organise data inside a relational database. A relational database stores data in tables — grids of rows and columns, much like a spreadsheet — and SQL is how you ask questions like “show me every engineer earning over 80,000” and get exactly those rows back.

--how it works
1

You write a statement

e.g. SELECT name FROM employees WHERE salary > 80000 — plain English-like keywords, no loops, no plumbing.

2

The engine parses it

The database checks your syntax and your column/table names against the schema, and rejects anything it cannot resolve before touching data.

3

The engine plans the work

It weighs indexes, table sizes and statistics to find the fastest internal strategy — you describe WHAT you want, it decides HOW.

4

Rows come back as a table

Matching rows return as a fresh result table — something you can read, sort, or feed straight into your application.

5

One language, reads and writes

SELECT reads, INSERT adds, UPDATE edits, DELETE removes, CREATE/DROP manage structure — the same grammar covers all of it.

--visualization
📱 Appwrites query🧾 SQLstatement🗄 Engineparse+plan📋 Resultrows foundSELECT name FROM employees WHERE salary > 80000;
Stage 1 / 5
Your app needs data. It writes the request in SQL — a language built for exactly that.
--example
query.sql
1SELECT name, salary FROM employees;
Result
namesalary
Alice85000
Cynthia91000
Farid73000

This reads the employees table, keeps only the name and salary columns, and returns every row. Three statements do 95% of daily work: SELECT (read), INSERT (add), UPDATE/DELETE (change).

--variants

Read — SELECT

Asks a question and returns a result table without changing anything stored.

query.sql
1SELECT name, salary FROM employees WHERE salary > 80000;
Result
namesalary
Alice85000
Cynthia91000
1The engine loads candidates from employees.
2The WHERE clause keeps only rows whose salary exceeds 80000.
3Projection keeps just the name and salary columns of the survivors.

Add — INSERT

Puts a brand-new row into a table.

query.sql
1INSERT INTO employees (id, name, department, salary, age)
2VALUES (7, 'Grace', 'Engineering', 81000, 31);
Result
idnamedepartmentsalaryage
7GraceEngineering8100031
1The column list declares exactly which fields you are supplying.
2One VALUES tuple must line up with that list, value for value.
3The row is appended; the engine reports "1 row inserted".

Change — UPDATE

Edits values in existing rows in place.

query.sql
1UPDATE employees SET salary = 88000 WHERE id = 1;
Result
idnamedepartmentsalaryage
1AliceEngineering8800029
1The WHERE clause selects which rows are touched — here, exactly one.
2SET assigns the new value; the old one is overwritten.
3Every other row is untouched because id is unique.

Structure — CREATE

The same language also defines the tables the data lives in.

query.sql
1CREATE TABLE departments (
2 dept_id VARCHAR(30) PRIMARY KEY,
3 location VARCHAR(30)
4);
1Two typed columns are declared — types keep the data honest.
2dept_id is the primary key, so two rows can never share one.
3The table exists empty, ready for INSERTs.
--key facts
StandardisedANSI SQL since 1986 — skills transfer across MySQL, PostgreSQL, SQLite, SQL Server
Declarativeyou describe WHAT you want, not HOW to loop — the engine optimises the how
Pronunciationeither “S-Q-L” or “sequel” — both are accepted everywhere
--use cases
Reading dashboards and reports: every chart on screen is a SELECT under the hood
App back ends: sign-ups, orders, posts — all INSERT/UPDATE/DELETE at the core
Analytics: "top 10 products last month" is a single GROUP BY + ORDER BY query
Data cleaning: find and fix bad rows with WHERE + UPDATE before analysis
--under the hood
Declarative: you describe the result, the optimiser chooses the execution plan — the reverse of imperative code.
ANSI-standard since 1986, so the fundamentals here transfer across MySQL, PostgreSQL, SQLite and SQL Server.

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books

Practice what you learned

Take the queries you just visualized and see the data structures that power real databases.