as
: FROM tbl AS t
as
: FROM tbl AS t
, exceptions exist: FROM JSON_TABLE(…) AS t
SQL allows renaming tables in from
and join
clauses by providing the optional keyword as
followed by the new table name. The table is only known by its new name in the clauses that follow in order of logical evaluation.
SELECT …
FROM tbl_a [AS] a
JOIN tbl_b [AS] b
The SQL standard requires every table in from
and join
to have a name. Therefore, tables that don’t have a natural name—such as sub-queries—must use this syntax to assign a name.
Some systems allow omitting a table name where the standard requires one.
E051-05, “Select list items can be renamed”
E051-08, “Correlation names in the FROM clause”, is a mandatory feature of ISO/IEC 9075-2:2023. It already appeared in ANSI X3.135-1989 but without the optional keyword as
, which was introduced with ISO/IEC 9075:1992 as part of the level “intermediate”. Accepting the keyword as
became mandatory with ISO/IEC 9075-2:1999.
You can’t catch up on 20 years of SQL evolution in one day. Subscribe the newsletter via E-Mail, Bluesky or RSS to gradually catch up and to keep modern-sql.com on your radar.
The essence of SQL tuning in 200 pages
Buy now!
(paperback and/or PDF)
Paperback also available at Amazon.com.
Markus offers SQL training and consulting for developers working at companies of all sizes.
Learn more »