SQLite: no such column (tested)
sqlite3.OperationalError: no such column: X fires whenever a query references a column name the table doesn't have — not just in the SELECT list. We reproduced it in three different clauses and measured one related, but distinct, error from a JOIN.
1. The same error, from three different places in a query
With a table defined as (id INTEGER, name TEXT), we triggered the identical error shape from the SELECT list, a WHERE clause, and ORDER BY:
con.execute("SELECT nmae FROM t")
sqlite3.OperationalError: no such column: nmae
con.execute("SELECT * FROM t WHERE age > 5")
sqlite3.OperationalError: no such column: age
con.execute("SELECT * FROM t ORDER BY missing_col")
sqlite3.OperationalError: no such column: missing_col
Measured: SQLite checks every column reference in the whole statement at compile time, before any row is read — it's not specific to what you're selecting. This is a different error from table has no column named, which is INSERT/UPDATE-specific wording for the same underlying fact (a name isn't in the schema).
2. A related but distinct error: ambiguous column in a JOIN
With two tables that both have a name column, an unqualified reference across a join gave a different message entirely:
con.execute("SELECT name FROM a JOIN b ON a.id = b.id")
sqlite3.OperationalError: ambiguous column name: name
This is the opposite problem: the column exists — twice — so SQLite can't tell which table you mean, rather than not finding it at all. Qualifying it (a.name) resolves this one; it does nothing for a genuine "no such column" since there's no name collision to resolve there.
3. The fix: check the schema, and qualify columns in joins
For "no such column," list the real columns on the table the query is actually running against:
PRAGMA table_info(t);
For "ambiguous column name," qualify the column with its table (or alias): SELECT a.name FROM a JOIN b .... We confirmed this fixes the JOIN case with no other change, and that it's unrelated to the missing-column case — the two errors measured here never overlap in cause.
Frequently asked questions
Does 'no such column' only happen in the SELECT list?
No — we measured it firing identically from a SELECT list, a WHERE clause, and an ORDER BY clause. SQLite validates every column reference in the full statement at compile time, not just what you're selecting.
What's the difference between 'no such column' and 'ambiguous column name'?
We reproduced both: 'no such column' means the name isn't in the schema anywhere reachable by the query. 'Ambiguous column name' means the opposite — it exists in more than one joined table, so SQLite can't pick one without qualification.
How do I fix an ambiguous column error from a JOIN?
Qualify the column with its table name or alias, e.g. a.name instead of name — we confirmed this resolves the ambiguous-column error from a two-table JOIN with no other change needed.
Is this the same as the 'has no column named' error?
They're the same underlying fact (a name isn't in the schema) with different wording depending on the statement type — we measured 'no such column' from SELECT/WHERE/ORDER BY and 'has no column named' specifically from INSERT/UPDATE.
Does qualifying columns in a JOIN prevent 'no such column' too?
Not by itself — we confirmed qualification only fixes ambiguity (a name that exists in multiple tables). If the column genuinely doesn't exist anywhere in the query's tables, qualifying it still fails with 'no such column'.
Written with AI assistance. Measured on 2026-10-03 with Python 3.13.5's built-in sqlite3 module, triggering the error from a SELECT list, a WHERE clause, an ORDER BY clause, and a two-table JOIN. Every error string below is copy-pasted output, not paraphrased. PlainHeaders is our extension; Python's sqlite3 is built in.