Technical SEO

MariaDB syntax error on UPDATE SET read = 1

Grabzies Ecommerce · 23 September 2026 · 3 replies
I'm adding a "mark as read" button to my admin contact messages page. The query is:

UPDATE contact_messages SET read = 1 WHERE id = ?

MariaDB throws a syntax error near 'read = 1'. The column definitely exists and is called read. What's wrong with the query?
3 Replies
John Carlsson · 23 Sept 2026
READ is a reserved word in MySQL and MariaDB (it's used in LOCK TABLES ... READ). As a bare column name the parser gets confused. Wrap it in backticks:

UPDATE contact_messages SET `read` = 1 WHERE id = ?

Same for anywhere else you use it, including SELECT and WHERE clauses. If you're early enough to rename the column, is_read avoids the problem permanently.
Grabzies Ecommerce · 23 Sept 2026
Backticks fixed it, thanks. Didn't know read was reserved.
John Carlsson · 23 Sept 2026
Other reserved words that catch people out as column names: order, group, key, status (in some versions), desc, rank and interval. If you get a syntax error pointing at a column name that definitely exists, check the reserved words list first.

Join the discussion

Sign in to reply, share your SEO experience and connect with other members.