I have this table:
create table TableName5 ( col1 varchar(200), col2 varchar(200), col3 varchar(200) generated
always as ('col1' + 'col2') stored );
The col3
is supposed to be a computed column – the value in col1
plus the value in col2
.
The create query works OK.
However trying to insert values:
insert into TableName5 (col1, col2) values ('a', 'b');
Results in
ERROR 1292 (22007): Truncated incorrect DOUBLE value: 'col1'
error.
What am I doing wrong?
EDIT:
I tried using a different create query:
create table TableName5 ( col1 varchar(200), col2 varchar(200), col3 varchar(200) generated
always as concat(col1, ' ', col2) stored );
but got a syntax error on it
2
Answers
in your original you had stings cl1 and clo2 so the result was col1col2
as i satd you can’t sum varchar or text you need CONCAT
fiddle