SQLite error SQLITE_ERROR
near "…": syntax error
SQLite’s parser reached the quoted word and couldn’t fit it into any valid statement. The mistake is at that word or right before it: often a reserved word used as a name, a missing or extra comma, or syntax from another database.
near "order": syntax error
Tested on SQLite 3.51.0 (macOS /usr/bin/sqlite3) · Updated 9 October 2026
What it means
SQLite reads your statement word by word. near "X": syntax error means that X is the first word
that can’t continue any valid statement, so SQLite stopped there. It returns SQLITE_ERROR
(code 1) and runs nothing.
The word in quotes is where SQLite gave up, not always where the mistake is. Look at it and at the
word right before it: in ALTER TABLE users DROP COLUMN IF EXISTS name, SQLite reads IF as the
column name and complains about EXISTS.
Two related messages: incomplete input means the statement ended too early (a missing ) or
END), and unrecognized token: "…" means a character SQLite doesn’t use at all, such as #,
:: or an unclosed quote.
Common causes
- A reserved word as a name.
order,group,from,indexandvaluescan’t be bare table or column names. - A missing or extra comma: between two column definitions, or a trailing comma before
FROMor). - Syntax from another database. MySQL’s
AUTO_INCREMENT,MODIFY,UPDATE … JOIN,SHOW TABLESandDESCRIBE; PostgreSQL’sILIKE,::textandADD COLUMN IF NOT EXISTS; SQL Server’sSELECT TOP 5. - A feature newer than your SQLite:
RETURNINGandDROP COLUMNneed 3.35.0,RIGHTandFULL OUTER JOINneed 3.39.0,UPDATE … FROMneeds 3.33.0, upsert (ON CONFLICT … DO) needs 3.24.0. Check withSELECT sqlite_version();. - Placeholders that didn’t become values. A
%sfrom another driver’s style, or a?used for a table or column name: parameters only stand for values. - Two statements without a semicolon between them.
How to fix it
Quote names that are keywords
Use double quotes for identifiers:
SELECT id, "order" FROM users;
CREATE TABLE groups ("group" TEXT);
SQLite also accepts MySQL’s backticks and SQL Server’s square brackets, but double quotes are the standard. Single quotes are for text values.
Check the commas
Read the list right before the quoted word. In CREATE TABLE t1(id INTEGER PRIMARY KEY name TEXT)
the error is near "name": the comma after PRIMARY KEY is missing.
Translate syntax from other databases
| If you wrote | In SQLite |
|---|---|
id INT AUTO_INCREMENT PRIMARY KEY | id INTEGER PRIMARY KEY (add AUTOINCREMENT only if ids must never be reused) |
SHOW TABLES | .tables in the shell, or SELECT name FROM sqlite_schema WHERE type = 'table' |
DESCRIBE users | PRAGMA table_info(users) |
name ILIKE 'a%' | name LIKE 'a%' (case-insensitive for ASCII letters by default) |
id::text | CAST(id AS TEXT) |
SELECT TOP 5 … | SELECT … LIMIT 5 |
UPDATE a JOIN b ON … SET … | UPDATE a SET … FROM b WHERE … |
ALTER TABLE t ADD COLUMN a …, ADD COLUMN b … | one ALTER TABLE t ADD COLUMN per column |
ALTER TABLE t MODIFY … / ALTER COLUMN … TYPE … | rebuild the table (create, copy, drop, rename) |
# comment | -- comment |
Pass values, not names, as parameters
SELECT * FROM ? fails with near "?". Bind values only; if the table name varies, choose it from
a fixed list in your code and put it in the SQL text, quoted.
Upgrade, or rewrite for an older SQLite
If the statement is valid for current SQLite but fails on a server or device, compare
SELECT sqlite_version(); there with the versions above. Without RETURNING, run a SELECT after
the write; without DROP COLUMN, rebuild the table.
Reproduce it
macOS /usr/bin/sqlite3, SQLite 3.51.0, which prints the position under the statement:
sqlite3 syn.db "SELECT id, order FROM users;"
Error: in prepare, near "order": syntax error
SELECT id, order FROM users;
^--- error here
The shell adds “Error: in prepare,” and the pointer; SQLite’s message is
near "order": syntax error. Others from the same session:
Error: in prepare, near "FROM": syntax error
SELECT id, name, FROM users;
^--- error here
Error: in prepare, near "AUTO_INCREMENT": syntax error
CREATE TABLE t2(id INTEGER PRIMARY KEY AUTO_INCREMENT, name TEXT);
error here ---^
Error: in prepare, near "EXISTS": syntax error
ALTER TABLE users DROP COLUMN IF EXISTS name;
error here ---^
Error: in prepare, near "?": syntax error
SELECT * FROM ?;
^--- error here
Error: in prepare, unrecognized token: ":"
SELECT id::text FROM users;
^--- error here
SHOW TABLES, DESCRIBE users, ILIKE, SELECT TOP 5, MODIFY, UPDATE … JOIN and two
ADD COLUMN clauses in one statement all failed the same way. SELECT "order" FROM users,
RETURNING, RIGHT JOIN and UPDATE … FROM worked on this version.
In Inlet
Inlet’s query editor highlights SQL as you type and completes table and column names from the live schema. When SQLite rejects a statement, Inlet shows the error at the position SQLite reports. With your own Anthropic API key, Ask Claude (⌘L) can fix a failed statement.