Below is what I have
+++++++++++++++
+ id + myData +
+++++++++++++++
+ 1 + ABCD +
+ 2 + ABCDD +
+++++++++++++++
When I execute
select char_length((select myData from mytable where id = 1)) as MyLength;
I get result as
++++++++++++
+ MyLength +
++++++++++++
+ 4 +
++++++++++++
But when I execute query,
select char_length((select myData from mytable) as MyLength;
I get error as
DDL and DML statements are not allowed in the query panel for MySQL; only SELECT statements are allowed.
You are wrapping the entire query output in
CHAR_LENGTH(). When applying theWHERE id = 1to the subquery, it returns a single row, and since you’ve selected a single column, you get one single string value back whichCHAR_LENGTH()will accept as its argument.If the subquery
select mySata from mytablereturns multiple rows,char_length()cannot accept it as an input. Instead, merely applyCHAR_LENGTH()tomyDatain a regularSELECTstatement to see the lengths of multiple rows.