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 Sharma[email protected]MumbaiIndia
C1002Sara Chen[email protected]SingaporeSingapore
C1003James Wilson[email protected]LondonUK
C1004Maria Garcia[email protected]MadridSpain
C1005Yuki Tanaka[email protected]TokyoJapan
C1006Priya Patel[email protected]DelhiIndia
C1007Alex Johnson[email protected]New YorkUSA
C1008Chen Wei[email protected]ShanghaiChina
C1009Emma Brown[email protected]SydneyAustralia
C1010Omar Hassan[email protected]DubaiUAE
C1011Lena Muller[email protected]BerlinGermany
C1012Ravi Kumar[email protected]BangaloreIndia

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
4 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