In my CREATE VIEW I would like to:
SELECT CONCAT( t.str1, t.str2 ) AS Title, CHAR_LENGTH( Title ) AS Length
but this ill produce error:
<You cannot refer the alias you created in SELECT
, use expression instead:
SELECT CONCAT( t.str1, t.str2 ) AS Title,
CHAR_LENGTH(CONCAT( t.str1, t.str2 ) ) AS Length
FROM table_name t
You can use subquery if you need:
SELECT sub.Title, CHAR_LENGTH( sub.Title ) AS Length
FROM (
SELECT CONCAT( t.str1, t.str2 ) AS Title
FROM table_name t
) AS sub;
All-at-once operation:
"All-at-Once Operations" means that all expressions in the same logical query process phase are evaluated logically at the same time.
and:
We cannot use an alias in next column expression in the SELECT clause. In the query we create a corrected first name and we want to use it in next column to produce the full name, but the All-at-Once operations concept tells us you cannot do this because all expressions in the same logical query process phase (here is SELECT) are evaluated logically at the same time.