Creating an alias for a result in a query is no problem
select VALUE as ALIAS from TABLE
But what if I want the alias to be dynamic? My first thought would be to have a subquery in the AS statement, but SQL hates it apparently.
select VALUE1 as (select VALUE2 from TABLE2 where A=B) from TABLE1
This throws an error:
.Incorrect syntax near '('.
first, aliases are just names they lives until query running. its useful when writing long complex queries and also if you have long ugly table names you can use alias for that. you can use AS
or just simply table_name alias
but you can't use as for set sub-queries.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.