TOPIC 04/2814 MINNOT STARTED

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.

  1. Select says what to show
  2. From says where it lives
  3. Where says which rows
Three words

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
LibrarianStructured Query Language (SQL)
Your requestselect query
Red, recent, newest firstFilter and order
ShelvesTables

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.

What each part of the trick stands for
In the trickWhat it stands for
Read-onlythe taught plain table SELECT reads rows
Filtera 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
  1. 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)

    Per the search excerpt, a vendor tutorial: select returns rows and the where clause, placed after from, keeps only the rows whose condition is true. Practitioner guidance, not a standard. · Checked 2026-10-18

    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.

  2. 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)

    Per the search excerpt, a tutorial: a left join with a test for a missing key on the right side finds rows that have no match, such as customers with no orders. Practitioner guidance, not a standard. · Checked 2026-10-18

    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.

  3. 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)

    Per the search excerpt, a vendor guide: group rows by the columns that should be unique, keep groups with a count above one, and leave out the primary key from the grouping. Practitioner guidance, not a standard. · Checked 2026-10-18

    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.

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

    Per the search excerpt, parameterized queries are the main defence because the database can tell code from data. Escaping all input is strongly discouraged. Practitioner guidance, not a standard. · Checked 2026-10-18

    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.

  5. 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.

    Difference among DELETE, TRUNCATE and DROP. · Checked 2026-10-19

    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.

  6. 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.

    TRUNCATE is rolled back if the surrounding PostgreSQL transaction does not commit. · Checked 2026-10-19

    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.

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

    Lists TRUNCATE TABLE among statements that end the active transaction; the TRUNCATE TABLE page says it cannot be rolled back. · Checked 2026-10-19

    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.

  8. 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.

    A free, precise, section-numbered description of the SQL a payments practitioner actually writes. Join types and what happens to unmatched rows, GROUP BY and HAVING against WHERE, window functions and the de-duplication and running-total idioms built on them. Transaction isolation levels and the anomalies each permits, index use, and null three-valued logic.

    Used here for the data-and-SQL questions a Payment Operations Analyst, a Production Support Analyst and a Sanctions Screening Analyst are asked. · Checked 2026-08-18

    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/postgres documentation 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.