1994
MariaDBERRORNotableQueryHIGH confidence
Every derived table must have its own alias
Production Risk
Low — query is rejected; no data is modified.
What this means
A subquery used as a derived table in the FROM clause was not given an alias. MySQL requires every derived table (inline view) in a FROM clause to be aliased.
Why it happens
- 1Subquery in FROM clause without an AS alias.
- 2Missing alias after a parenthesised subquery used as a table.
How to reproduce
trigger — this will error
trigger — this will error
SELECT * FROM (SELECT id, name FROM users);
expected output
ERROR 1994 (42000): Every derived table must have its own alias.
Fix
Add an alias to the derived table
Add an alias to the derived table
SELECT * FROM (SELECT id, name FROM users) AS u;
Why this works
The alias gives the derived table a name so the outer query can reference it.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 1994 ER_DERIVED_MUST_HAVE_ALIAS
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev