SQL Tutorial: Getting Started with SQL
What SQL is, how databases work, and your first SELECT query.
What is SQL?
SQL (Structured Query Language) is the standard language for working with **relational databases** — think MySQL, PostgreSQL, SQLite, and SQL Server.
A relational database stores data in **tables**, like spreadsheets:
```
users table:
┌────┬─────────┬───────────────────┐
│ id │ name │ email │
├────┼─────────┼───────────────────┤
│ 1 │ Alice │ alice@example.com │
│ 2 │ Bob │ bob@example.com │
│ 3 │ Carol │ carol@example.com │
└────┴─────────┴───────────────────┘
```
SQL lets you query, insert, update, and delete data in these tables.
---
Your First Query
```sql
SELECT name, email FROM users;
```
- `SELECT` — choose which columns to return
- `FROM` — specify the table
Retrieve all columns with `*`:
```sql
SELECT * FROM users;
```
---
Comments
```sql
-- This is a single-line comment
/*
This is a
multi-line comment
*/
SELECT 'Hello, SQL!' AS greeting;
```
---
Expressions and Aliases
```sql
SELECT
2 + 2 AS sum,
'Hello' || ' World' AS message,
UPPER('sql') AS upper_sql;
```
The `AS` keyword renames the output column.
---
What's Next?
Next: **SELECT and WHERE** — filter rows with conditions.
What you'll learn in this SQL getting started with sql tutorial
This interactive SQL tutorial has 3 hands-on exercises. Estimated time: 10 minutes.
- Your first query against a real database — You have access to a real company database with 5 tables:
- SELECT specific columns — don't fetch what you don't need — Selecting `*` fetches every column. In production, that wastes bandwidth and exposes sensitive fields. Always name the c…
- COUNT — how big is the dataset? — Before writing complex queries, it's useful to understand the scale of the data. `COUNT(*)` tells you exactly how many r…
SQL Getting Started with SQL concepts covered
- What is SQL?
- Your First Query
- Comments
- Expressions and Aliases
- What's Next?