I have created table as
create table tab (id int, mytext varchar(200));
Now I inserted values as
insert into tab values
(1, 'text 11,text 12,'),
(2, 'text 21,text 22,'),
(3, 'text 31,text 32,'),
(4, 'text 41,text 42,');
Now what I wanted to do is add text text none, at the start of the text. For that I had to execute query as
update tab set mytext = concat('text none,', mytext)
However, mistakenly I executed the query as:
update tab set mytext = concat('text none', mytext)
I missed the COMMA (,) after ‘none’.
Now I have data as
1 textnonetext 11,text 12,
2 textnonetext 21,text 22,
3 textnonetext 31,text 32,
4 textnonetext 41,text 42,
What I want is change above output to:
1 textnone,text 11,text 12,
2 textnone,text 21,text 22,
3 textnone,text 31,text 32,
4 textnone,text 41,text 42,
i.e. add comma(,) after none.
Any idea how to get this done?
SQL Fiddle for testing
Note : The length of the original data in the mytext fields is not fixed; for some ids it’s 6, for some it’s 50.
Try this one,
SQLFiddle Demo
or simply do replace if you don’t have any special reason to use concat