Introduction to SQL
The language every database speaks — and why you should too
What is SQL?
SQL (Structured Query Language) is how you communicate with relational databases. You describe what data you want, and the database figures out how to retrieve it. Here's how it all fits together:
Core Mechanics
How SQL actually works under the hood
- You describe WHAT you want — the engine decides HOW
- Tables = columns (fields) + rows (records)
- Keys connect tables to form relationships
- One query can filter, sort, join, and aggregate millions of rows
Mental Model
Think of SQL as a conversation
SQL reads like English when you follow the logical flow. The database translates your request into an optimized execution plan.
- "Hey database, FROM this table…"
- "…SELECT these columns…"
- "…WHERE this condition is true…"
- "…and ORDER BY this column."
SQL vs Programming Languages
What makes SQL fundamentally different
Where SQL Shows Up
SQL is everywhere in tech
- Dashboards & analytics reports
- Backend APIs & data pipelines
- Ad-hoc data exploration
- ETL jobs & data warehouses
- Machine learning feature engineering
Quick Revision
5-second refresher
- SQL = Structured Query Language
- Tables store data in rows and columns
- SELECT ... FROM ... is the most basic query
- Every major database speaks SQL
- Declarative: say what, not how
SELECTTells the database which columns you want to seeFROMTells the database which table to look in;Ends the SQL statement — required to separate multiple statements; many tools accept a single statement without it| id | name | city | country | |
|---|---|---|---|---|
| C1001 | Aarav Sharma | [email protected] | Mumbai | India |
| C1002 | Sara Chen | [email protected] | Singapore | Singapore |
| C1003 | James Wilson | [email protected] | London | UK |
| C1004 | Maria Garcia | [email protected] | Madrid | Spain |
| C1005 | Yuki Tanaka | [email protected] | Tokyo | Japan |
| C1006 | Priya Patel | [email protected] | Delhi | India |
| C1007 | Alex Johnson | [email protected] | New York | USA |
| C1008 | Chen Wei | [email protected] | Shanghai | China |
| C1009 | Emma Brown | [email protected] | Sydney | Australia |
| C1010 | Omar Hassan | [email protected] | Dubai | UAE |
| C1011 | Lena Muller | [email protected] | Berlin | Germany |
| C1012 | Ravi Kumar | [email protected] | Bangalore | India |
Worked Example
List all customer names and their cities.
| name | city |
|---|---|
| Aarav Sharma | Mumbai |
| Sara Chen | Singapore |
| James Wilson | London |
| Maria Garcia | Madrid |
Forgetting the FROM clause
SQL needs to know which table to look in. Without FROM, the database does not know where name and city come from.
Always pair SELECT with FROM: SELECT columns FROM table_name;
Key Concepts
Pro Tip
SQL is the most widely used data language on earth. Every major database — PostgreSQL, MySQL, SQLite, Snowflake, BigQuery — speaks it. Analysts, engineers, PMs, and backend developers use it daily.
When to Use
Every dashboard, every filtered product listing, every analytics report — almost certainly has SQL behind it. Learning SQL gives you direct access to data without waiting for someone else to pull it.
Write a query to select the name and email of all customers.