How can I use an alias in the same statement? See the body alias in the statement below. When I use it in sum(length(body), I get unknown column.
SELECT substring_index(userBody, ' ', 60) as body, SUM(LENGTH(body)-LENGTH(REPLACE(body,' ',''))+1) as wordCount
from articles where artcId = 10;
You can’t use
bodyalias name in the next select column, Better use the same ‘alias’ block in the following sections. See the below query for more clarification.