TOPIC 06/2816 MINNOT STARTED

Patterns, lists, ranges and aliases: LIKE, IN, BETWEEN and AS

Check data by a pattern, a list or a range, give columns short names, and learn the order a query really runs in, so your checks give the answer you meant.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: a car wash. The car goes through the same stations in the same order. You cannot ask the polish station to decide which cars get rinsed. A query has stations too, and they do not run in the order you type them.

Daily List is a to-do list app. Tom searches titles for the word milk, and he keeps only open or waiting tasks. He also learns why a short name works in one station and fails in another. (SYNTHETIC / TRAINING ONLY: Daily List and the people here are invented.).

What it is: LIKE, IN and BETWEEN are (Structured Query Language) tests. SQL asks a database a question. A table is a grid. A row is one task. A column is one fact, such as the title or the status. A uses LIKE. IN matches a list. BETWEEN matches a range, and both ends count. The neighbour of LIKE is =, which matches the whole value only. A short name in a query, made with AS, is not a column in the table. The query run steps decide where that name is legal.

Why it matters: A search can miss Pay rent. It can also keep a done task. The pattern or the list was a step off. The screen still looks like a normal list.

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 A car wash that runs its stations in a fixed order.

  1. Rinse
  2. Soap
  3. Polish
Car wash

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
The rinse stationFROM
The soap stationWHERE
The polish stationSELECT
The queue order at the exitORDER BY

WHERE THIS PICTURE STOPS

  • A car wash is a place, but a query is a plan.
  • Cars move once, but the engine may reorder work.
  • Stations never change, but products differ in details.

HOOK

Stations run in order.

TELL A FRIEND

A car wash: polish comes last.

OFTEN MIXED UP WITH SQL (Structured Query Language) filtering, sorting and totals for testers. That topic covers filtering, sorting and totals. This one adds patterns, lists, ranges, short names and the run steps.

PRACTISE AND KEEP

Sources for this topic — 3 sources
  1. Market practice

    Pattern matching (PostgreSQL documentation) ↗ — PostgreSQL · PostgreSQL reference: in a LIKE pattern an underscore matches any one character, a percent sign matches any run of characters including none, and the pattern must match the whole string (search excerpt, page not opened)

    §9.7 LIKE/ILIKE, escaping and collation scope. PostgreSQL18 implementation, not a universal SQL mandate. · Checked 2026-11-06

    PostgreSQL18 publisher documentation opened on6November2026: §9.7 LIKE/ILIKE, escaping and collation scope. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.

  2. Market practice

    SELECT command reference (PostgreSQL documentation) ↗ — PostgreSQL · PostgreSQL select reference: the where clause filters rows before grouping, and output names can be given with as (search excerpt, page not opened)

    SELECT: WHERE/HAVING/output aliases, functional dependence, NULL ordering and LIMIT. PostgreSQL18 implementation, not a universal SQL mandate. · Checked 2026-11-06

    PostgreSQL18 publisher documentation opened on6November2026: SELECT: WHERE/HAVING/output aliases, functional dependence, NULL ordering and LIMIT. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.

  3. Implementation-specific

    PostgreSQL documentation ↗ — The PostgreSQL Global Development Group · PostgreSQL 18 official manual, opened 2026-11-06: functions-matching §9.7 and sql-select. 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.