SQL has outlasted every database technology of the last 40 years. PostgreSQL powers Instagram, Reddit, Apple iCloud. Snowflake hit $4B ARR in 2024 — selling SQL. Learning SQL well is the highest-ROI 20 hours in your data career.
Learning Objectives
After this lesson, you will be able to:
Explain what a relational database is and why companies bet on Postgres, Snowflake, and BigQuery in 2025
Identify the three building blocks of a relational database: tables, rows, and columns
Write a SELECT * FROM table query to retrieve all data from a table
Use SELECT with specific column names to retrieve only the data you need
Apply LIMIT to control how many rows you get back
Read and understand query results displayed in a table format
Explain why SQL is still the universal language of data 50 years after Codd invented it
What Is a Database?
Your Reflection
Saves automatically
What’s one thing you learned? What’s still confusing?
You are about to learn the most in-demand data skill on the planet. SQL has been around since the 1970s and is more relevant today than ever. Every data scientist, ML engineer, and backend developer uses it daily. You have got this.
Think about a spreadsheet -- Google Sheets or Excel. You have rows, columns, and data in cells. A database is like a collection of spreadsheets, but with superpowers:
It can hold millions (or billions) of rows without slowing down
Multiple people can read and write data at the same time
SQL (Structured Query Language) is how you talk to a database. Your first command is SELECT, which means "give me data."
The simplest possible query:
sql
SELECT * FROM employees;
Let us break this down word by word:
SELECT -- "I want to retrieve data"
* -- "give me ALL columns" (the asterisk means "everything")
FROM employees -- "from the table called employees"
; -- the semicolon marks the end of the query (like a period at the end of a sentence)
That is it. Three words and a semicolon. You just asked the database: "Show me everything in the employees table."
Try it! Click "Run" in the playground below. You just queried a database. You are officially a SQL developer now.
Loading visualization...
Congratulations -- you just ran your first SQL query! The database read your question, found all the data in the employees table, and returned it to you as a neat table of results. Every row is one employee, every column is one piece of information about them.
What Do You Think?
What does SELECT * FROM orders; return?
The answer is all rows and all columns from the orders table. The * means "every column" and without a WHERE clause, you get every row. It is the broadest possible query -- give me everything.
Getting every column with * is great for exploring, but in real work you usually only need certain columns. Instead of *, list the column names you want:
sql
SELECT name, department FROM employees;
This gives you only the name and department columns -- nothing else. The result looks like:
name
department
Alice Johnson
Engineering
Bob Smith
Engineering
Carol Davis
Marketing
...
...
Why would you do this instead of SELECT *?
Speed -- fetching 2 columns is faster than fetching 10, especially with millions of rows
Clarity -- you see exactly the data you need, nothing extra
Best practice -- in production code, SELECT * is considered lazy. Always name your columns
You can select as many columns as you want, separated by commas:
sql
SELECT name, salary, hire_date FROM employees;
Try it! Modify the query below to select only name and salary. Then try adding department as a third column.
What if a table has 10 million rows and you just want to peek at the first few? That is what LIMIT does:
sql
SELECT * FROM employees LIMIT 3;
This returns only the first 3 rows. It is like saying "show me a sample."
sql
-- See the first 5 employees
SELECT * FROM employees LIMIT 5;
-- See just the first row
SELECT * FROM employees LIMIT 1;
-- Combine with specific columns
SELECT name, salary FROM employees LIMIT 3;
Try it! Change the LIMIT number in the playground below. Try LIMIT 1, LIMIT 5, and LIMIT 100 (what happens when you request more rows than exist?).
Loading visualization...
When you use LIMIT 100 but the table only has 10 rows, you get all 10 rows. No error. The database just gives you everything it has, up to your limit.
What Do You Think?
What does SELECT name FROM employees LIMIT 2; return?
The answer is the first 2 names from the employees table. SELECT name picks the column, LIMIT 2 caps the output at 2 rows. You get a single column with two values.
#SQL Is Not Case-Sensitive (But Conventions Matter)
SQL keywords are case-insensitive. All of these are identical:
sql
SELECT * FROM employees;
select * from employees;
Select * From Employees;
SeLeCt * fRoM eMpLoYeEs;
They all work. But the convention is:
SQL keywords in UPPERCASE:SELECT, FROM, WHERE, LIMIT
Table and column names in lowercase:employees, name, salary
This makes queries easier to read at a glance. You can instantly see which words are SQL commands and which are your data.
sql
-- Good style (recommended)
SELECT name, salary FROM employees LIMIT 10;
-- Works but harder to read
select name, salary from employees limit 10;
A real database has many tables. The sample database in this playground has three:
employees -- people who work at the company
orders -- purchases made by customers
products -- items for sale
Each table stores a different kind of data. You query them the same way:
sql
-- See all orders
SELECT * FROM orders;
-- See all products
SELECT * FROM products;
-- Peek at the orders table
SELECT customer_name, product, amount FROM orders LIMIT 5;
Try it! Explore all three tables below. Start with SELECT * FROM orders;, then try SELECT * FROM products;.
Loading visualization...
Later, you will learn how to combine data from multiple tables using JOINs. For now, just know that each table holds one type of data, and you can query any of them.
Like any language, SQL lets you write comments -- notes for yourself (or future you) that the database ignores:
sql
-- This is a single-line comment. Everything after -- is ignored.
SELECT name, salary -- you can put comments at the end of a line too
FROM employees;
/* This is a
multi-line comment.
Useful for longer explanations. */
SELECT * FROM products;
Comments are your friend. Use them to explain WHY you wrote a query a certain way, especially for complex queries.
A database is a collection of tables, each holding a specific type of data. Tables have rows (records) and columns (fields)
SELECT is the fundamental SQL command -- it retrieves data from a table. SELECT * gets all columns, SELECT name, salary gets specific columns
FROM specifies which table to query. Every SELECT needs a FROM
LIMIT controls how many rows you get back. Essential for previewing large datasets (in BigQuery/Snowflake, LIMIT also caps bytes scanned — saves real money)
SQL keywords are case-insensitive but the convention is UPPERCASE keywords, lowercase table/column names
Comments use -- for single-line and /* */ for multi-line. Use them generously
Quick Check1 / 5
What does the * mean in SELECT * FROM employees?
What's next: You can now retrieve data from any table — that's already 30% of daily SQL work. Next lesson, you'll learn to filter rows with WHERE (the difference between "show me 10 million orders" and "show me Alice's order from yesterday") and sort them with ORDER BY. Together, SELECT + WHERE + ORDER BY + LIMIT is enough to answer most business questions you'll ever hit.