I have a column with a string in it, and due to a bug some of the string values are wrong. So I want to fix the strings by taking the original string and concatenating information from a select to it. Ideally it would be something like:
UPDATE table as t
SET t.string = SELECT CONCAT(t.string,
(SELECT fix FROM othertable where id=t.id )
);
But of course, I can’t do that using concat.
I have to say I’ve not got very far with any other method.
Anyone have an ideas?
If the subquery is guaranteed to return just one value, you could simply drop the
SELECTkeyword beforeCONCAT:If the subquery may return more than one value, a quick fix could be to apply
GROUP_CONCATlike this: