Introduction to SQL

The language every database speaks — and why you should too

Beginner 10 minfundamentals

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:

Tables are the foundation — A database stores data in tables with columns (fields like name, email, price) and rows (individual records). Think of them as powerful spreadsheets that can hold millions of rows.
Keys connect tables — Tables reference each other through shared columns called keys. This is what makes databases "relational" — data is linked across tables, not duplicated everywhere.
Queries are your questions — "Show all customers from India," "What's the average order value?" — these are queries written in SQL, and learning to write them is what this entire course is about.
SQL is declarative — Unlike most languages where you write step-by-step instructions, SQL lets you describe *what* you want. No loops, no iteration. The database handles the *how* behind the scenes.

Knowledge Canvas

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

Declarative — describe the result
Imperative — describe the steps
Set-based — operates on groups of rows
Loop-based — processes one item at a time
No variables, no loops, no if/else
Full control flow with variables and conditionals
Engine optimizes execution for you
You manage performance manually

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

Syntax

Syntax Template
1SELECT
2 column1,
3 column2
4FROM table_name;
SELECTTells the database which columns you want to see
FROMTells the database which table to look in
;Ends the SQL statement — required to separate multiple statements; many tools accept a single statement without it

Sample Data

customers
12 rows
idnameemailcitycountry
C1001Aarav Sharmaaarav@email.comMumbaiIndia
C1002Sara Chensara@email.comSingaporeSingapore
C1003James Wilsonjames@email.comLondonUK
C1004Maria Garciamaria@email.comMadridSpain
C1005Yuki Tanakayuki@email.comTokyoJapan
C1006Priya Patelpriya@email.comDelhiIndia
C1007Alex Johnsonalex@email.comNew YorkUSA
C1008Chen Weiwei@email.comShanghaiChina
C1009Emma Brownemma@email.comSydneyAustralia
C1010Omar Hassanomar@email.comDubaiUAE
C1011Lena Mullerlena@email.comBerlinGermany
C1012Ravi Kumarravi@email.comBangaloreIndia

Worked Example

List all customer names and their cities.

SQL
1SELECT
2 name,
3 city
4FROM customers;
This query asks for just two columns — name and city — from the customers table. SQL returns every row in the table because we have not applied any filter. The order of columns in your SELECT determines the order they appear in the result.
Output
First 4 of 12 rows
namecity
Aarav SharmaMumbai
Sara ChenSingapore
James WilsonLondon
Maria GarciaMadrid

Common Mistakes

❌

Forgetting the FROM clause

SQL
1SELECT
2 name,
3 city;

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

1You describe WHAT you want — the database decides HOW to get it
2One query can filter, combine, and summarize millions of rows
3Every major database speaks a SQL dialect — PostgreSQL, MySQL, SQLite, Snowflake (BigQuery uses GoogleSQL, a SQL-family dialect with extensions)
4No loops, no iteration — SQL handles rows as sets

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.

Challenge

Solve the problem below

Write a query to select the name and email of all customers.

Your Query