Looking at data with SQL SELECT
A select query only looks and never changes. With a few clauses a tester can find one row, count rows, spot repeats and find rows with no match.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: asking a librarian. You say, give me the red books published after 2020, newest first. The librarian brings a list. No book is moved, and no shelf is changed.
Daily List is a to-do list app. Tom has just saved a task on the screen. He wants the row the database stored, and he does not want to change anything.
What it is: (Structured Query Language) is a language for asking a database a question or changing it. A table is a grid, a row is one item, and a column is one fact about that item. The plain table taught here reads rows without changing them. It names the columns you want and the table to take them from. A filter keeps some rows and drops the rest. SELECT is easy to mix up with UPDATE or DELETE, which change rows. WHERE is easy to mix up with HAVING, which filters groups after they are counted.
Why it matters: The screen shows what the app chooses to show. The select query shows what was stored. If the two disagree, Tom has a fault to report, and he has the row to paste into the report.
A librarian can refuse a silly question. A database will run what it is given. Some commands do change data. A tester who only wants to look must stay with SELECT.
(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Reading what the database really stored, without changing it.
- Select says what to show
- From says where it lives
- Where says which rows
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| Librarian | Structured Query Language (SQL) |
| Your request | select query |
| Red, recent, newest first | Filter and order |
| Shelves | Tables |
WHERE THIS PICTURE STOPS
- A librarian can refuse a silly request. A database runs what it is given.
- A librarian never moves a book by accident. A wrong command can change data.
- A shelf has one order. A table can be sorted many ways.
HOOK
Select, from, where.
REMEMBER IT THIS WAY
A rule of thumb: if you see this, think that.
To check what was stored, ask the database with a read-only select and a filter for your one task.
| In the trick | What it stands for |
|---|---|
| Read-only | the taught plain table SELECT reads rows |
| Filter | a condition that picks some rows, so he gets his one task |
A plain table SELECT shows visible stored rows, not their cause.
TELL A FRIEND
Asking a librarian for all recent red books, newest first. A query asks a database in the same way.
OFTEN MIXED UP WITH Databases for testers. The databases lesson names tables and keys. This lesson asks questions of them.
PRACTISE AND KEEP
Sources for this topic — 8 sources
- Market practice
PostgreSQL WHERE (Neon PostgreSQL tutorial) ↗ — Neon · SELECT returns rows and the WHERE clause, placed after FROM, keeps only rows whose condition is true (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
PostgreSQL left join (Hyring learning pages) ↗ — Hyring · A left join with a test for a missing key on the right side finds rows that have no match (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
How to find duplicate rows in PostgreSQL (Command Prompt education) ↗ — Command Prompt · Group by the columns that should be unique, keep groups with a count above one, and leave the primary key out of the grouping (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Structured Query Language (SQL) injection prevention cheat sheet (Open Worldwide Application Security Project) ↗ — Open Worldwide Application Security Project (OWASP) · Building a query by pasting user text into it opens the door to injection; use parameters instead (registry entry staged in batch 11)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
V34 review, 6 November 2026: Read complete official repository sheet. Bind values; dynamic SQL structure requires separate safe handling, and object authorisation remains distinct.
- Market practice
SQL interview questions: DELETE, TRUNCATE, DROP (SQL Academy) ↗ — SQL Academy · PostgreSQL side checked by running BEGIN, TRUNCATE, ROLLBACK on 16.15 (row count stayed 1). MySQL side from sql-academy interview page excerpt and common knowledge of MySQL implicit commit. Official MySQL and PostgreSQL pages now cited. Official page checked 2026-10-19 by WebSearch: search excerpt, page not opened.
Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
TRUNCATE (PostgreSQL documentation) ↗ — PostgreSQL Global Development Group · PostgreSQL side checked by running BEGIN, TRUNCATE, ROLLBACK on 16.15 (row count stayed 1). MySQL side from sql-academy interview page excerpt and common knowledge of MySQL implicit commit. Official MySQL and PostgreSQL pages now cited. Official page checked 2026-10-19 by WebSearch: search excerpt, page not opened.
Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Statements That Cause an Implicit Commit (MySQL 8.0 Reference Manual) ↗ — Oracle / MySQL · PostgreSQL side checked by running BEGIN, TRUNCATE, ROLLBACK on 16.15 (row count stayed 1). MySQL side from sql-academy interview page excerpt and common knowledge of MySQL implicit commit. Official MySQL and PostgreSQL pages now cited. Official page checked 2026-10-19 by WebSearch: search excerpt, page not opened.
Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Implementation-specific
PostgreSQL documentation ↗ — The PostgreSQL Global Development Group · PostgreSQL 18 official manual, opened 2026-11-06: tutorial-select, queries-limit, functions-comparison and sql-truncate. Supports only PostgreSQL behavior; earlier execution evidence remains separately versioned.
An implementation, not the standard — which is the point. ISO/IEC 9075-2 is paywalled, and this documents the same constructs in text anybody can open. Its isolation-level chapter attributes to the standard explicitly, so it can carry a standard-level claim as long as the citation says which document it is quoting.
Cited as market practice rather than an official standard by kind: an engine's manual is authoritative about that engine and is not the obligation. Where a question turns on behaviour PostgreSQL chose rather than behaviour SQL requires, the answer has to say so.
One correction carried here because it circulates widely: the sentence "The fundamental difference between WHERE and HAVING…", quoted all over the internet as PostgreSQL documentation, is not in the current documentation. It was searched for in the source tree and is not there.
Read through a mirror, because the publisher's own domain could not be fetched (a reachability gap, not a statement about the publisher). A 403 there is a policy refusal and says nothing about whether the document exists or is reachable elsewhere.
Anyone on an unrestricted network should open the canonical URL above and confirm the section and page numbers cited against it. Every claim drawn from this entry is written so that it can be checked against a numbered page.
Read from the
postgres/postgresdocumentation source tree (doc/src/sgml), which the project itself maintains and which carries the section ids the published URLs are derived from — so a cited section id can be checked against the rendered page.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.