I need to select a value from a column in the table as a name of the another column in mysql
for ex ::
select column AS (select column from table where id = 1) from table;
it give me a syntax error .. How can I use select statement inside AS Function
Actually I need to set a value from a column as a name to another column using AS Function in mysql
2
Answers
The answer is simple: It is not possible in SQL. Column aliases are constants.
You can’t do this in a single query. All identifiers must be fixed in the query at the time it is parsed, which is before the query begins reading data. This includes column names and column aliases. The names or aliases of columns cannot be set at runtime based on data read during the query.
But you can do what you want in two queries.