SQL is the standardized language for talking to relational databases, and almost all of it is built from a small, learnable set of statements and clauses. This guide is the map: the families of SQL commands, the operators that power your conditions, and — because syntax sticks when you use it — a live playground where you assemble a real query clause by clause. The playground runs entirely in your browser against sample customers, orders, and products tables.
The anatomy of a query
Most of the SQL you write day to day is one statement — SELECT — built from clauses in a fixed order: pick columns, choose a table, filter rows, group and sort. Run this, then use the chips to add a clause at a time and watch the result change:
Build a query, clause by clause
Sample tables you can query
The clauses always run in the same logical order — FROM → WHERE → GROUP BY → ORDER BY — even though you write SELECT first. Each has its own guide: the SELECT list, the FROM table, the WHERE filter, and limiting rows with TOP/LIMIT.
The four families of SQL statements
Every SQL command falls into one of four sublanguages:
Data Manipulation Language (DML) — work with the rows
- SELECT — retrieve rows from one or more tables.
- INSERT INTO — add new rows.
- UPDATE — modify existing rows.
- DELETE FROM — remove rows.
Data Definition Language (DDL) — shape the structure
- CREATE TABLE — define a new table’s columns, types, and constraints.
- ALTER TABLE — change an existing table.
- CREATE INDEX — speed up retrieval on a column.
- CREATE VIEW — save a query as a virtual table.
Data Control Language (DCL) — manage access
Transaction Control (TCL) — commit or undo
- COMMIT saves the work in the current transaction; ROLLBACK discards it. Together they make a group of changes all-or-nothing.
The operators that power conditions
Clauses like WHERE, ON, and HAVING are built from operators:
- Comparison —
=,<>,<,>,<=,>=, plusIN,BETWEEN,LIKE, andIS NULL. - Logical —
AND,OR,NOTto combine conditions. - Arithmetic —
+,-,*,/; and the string concatenation operator||(orCONCAT).
Joining and aggregating
Two more clauses turn SQL from a lookup tool into an analytics one. A JOIN combines rows from related tables:
JOIN two tables
Sample tables you can query
…and GROUP BY with an aggregate function collapses many rows into a summary:
GROUP BY + aggregate
Sample tables you can query
Practice
Return the name and price of every product that costs more than $30, most expensive first. Select name and price.
Sample tables you can query
Frequently asked questions
What are the main types of SQL commands? Four families: DML (SELECT/INSERT/UPDATE/DELETE) works with rows, DDL (CREATE/ALTER/DROP) defines structure, DCL (GRANT/REVOKE) controls access, and TCL (COMMIT/ROLLBACK) manages transactions.
What order do SQL clauses go in? You write SELECT … FROM … WHERE … GROUP BY … HAVING … ORDER BY … LIMIT. The database evaluates them starting from FROM, which is why an alias defined in SELECT can’t be used in WHERE.
Is SQL syntax the same across databases? The core — SELECT, WHERE, joins, GROUP BY — is standardized and nearly identical. The differences are at the edges: row-limiting (LIMIT vs TOP), string functions, and DDL specifics.
From syntax to shipping data
Knowing the syntax is step one; the real job is moving and reshaping data across systems, repeatedly and reliably. ET1 is a visual, asynchronous ETL tool where these clauses become nodes on a canvas — filter, join, group, and aggregate — pointed at CSVs, databases, and APIs, with a live preview at every step.
Start anywhere in the series: SELECT, the WHERE clause, joins, or GROUP BY.