3153
MySQLERRORNotableJSONHIGH confidence
JSON_TABLE requires an alias
Production Risk
Low — compile-time error; easy to fix.
What this means
Every JSON_TABLE() function call in the FROM clause must have a table alias. Without an alias, MySQL cannot reference the virtual table in other parts of the query.
Why it happens
- 1JSON_TABLE() used in FROM clause without a table alias (AS alias_name).
How to reproduce
trigger — this will error
trigger — this will error
SELECT * FROM JSON_TABLE('[]', '#x27; COLUMNS(id INT PATH '$.id'));expected output
ERROR 3153 (42000): Every table function must have an alias.
Fix
Add a table alias to JSON_TABLE
Add a table alias to JSON_TABLE
SELECT * FROM JSON_TABLE('[]', '#x27; COLUMNS(id INT PATH '$.id')) AS jt;Why this works
The alias makes the virtual table referenceable in SELECT, WHERE, and JOIN clauses.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3153 ER_JSON_TABLE_ALIAS_REQUIRED
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev