I need to update column values (say column2) with concatenation of two string variables (say str1 & str2) with another column (say column1). Final value which I need in column2 is str1 as prefix and str2 as suffix to column1 value.
One way which can be done is with a dummy third column and a total of 4 update queries.
update table set column3 = str1;
update table set column2 = concat(column3, column1);
update table set column3 = str2;
update table set column2 = concat(column2, column3);
But I want to reduce that to a single update without using a dummy column, like below –
update table set column2 = concat($str1, column1, $str2);
I need help in the concat part of the above query.
There’s no reason this not to work: