SELECT
ELI5 — The Vibe Check
SELECT is how you ask a database to give you data. It is the 'Read' in CRUD. You say SELECT and then tell it exactly what you want: which table, which columns, which rows. It is basically asking the database a question.
Real Talk
SELECT is the SQL statement for querying data from one or more tables. It supports filtering (WHERE), joining tables (JOIN), sorting (ORDER BY), grouping (GROUP BY), limiting results (LIMIT), and aggregating data (COUNT, SUM, AVG). It is the most commonly used SQL statement.
Show Me The Code
SELECT id, name, email
FROM users
WHERE active = true
ORDER BY created_at DESC
LIMIT 10;
When You'll Hear This
"Write a SELECT query to get all active users." / "SELECT * is fine for debugging but bad for production."
Related Terms
CRUD (Create, Read, Update, Delete)
CRUD is the four things you can do to data: Create it, Read it, Update it, Delete it. Literally every app ever made is just CRUD in a trenchcoat.
JOIN
JOIN combines rows from two tables based on a related column.
LIMIT
LIMIT caps how many rows a query returns. If your users table has 1 million rows, you do not want to load all of them at once.
ORDER BY
ORDER BY sorts your query results. Add DESC for newest first, ASC for oldest first.
WHERE
WHERE is how you filter which rows a query affects. Without WHERE, SELECT returns everything, UPDATE changes everything, DELETE deletes everything.