Common errors

“no such table”, “no such column”, syntax errors, and constraint failures — what they mean in SQLite.

Runs in Zerethon IDE · SQLite 3 Official SQL documentation ↗
  • no such table: students — every run starts empty: create the table in a setup/ file or in the same file before using it (or load data/students.csv).
  • no such column: nmae — a typo, a column from a table that is not in FROM, or a text value written with double quotes (use single quotes for text: 'Ada').
  • near "FROM": syntax error — look just before the word shown: often a missing or extra comma.
  • ambiguous column name: id — several joined tables have that column; prefix it (s.id).
  • UNIQUE constraint failed: students.id — a row with that key already exists; use another key, or INSERT OR IGNORE / ON CONFLICT.
  • NOT NULL constraint failed: books.title — a required column was left out.
  • misuse of aggregate function count() — an aggregate in WHERE; move the condition to HAVING.
main.sql
CREATE TABLE IF NOT EXISTS tags (name TEXT PRIMARY KEY);
INSERT OR IGNORE INTO tags VALUES ('sql'), ('sql'), ('db');

SELECT count(*) AS tags FROM tags;

Result

tags
2
IF NOT EXISTS and OR IGNORE avoid errors you expect: the duplicate 'sql' is skipped.