Reputation: 2243
Is there a MySQL function to easily insert a character or characters into the value of a varchar column?
I want to set the following text:
B U 1 U 09 2011 Segs 1, 3 - 10 24 hours
To
B U 1 U N 09 2011 Segs 1, 3 - 10 24 hours
Upvotes: 1
Views: 1492
Reputation: 3771
Try:
SELECT INSERT('B U 1 U 09 2011 Segs 1, 3 - 10 24 hours', 8, 0, ' N');
SQL Fiddle: http://sqlfiddle.com/#!2/d41d8/3998
More info: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_insert
Upvotes: 0
Reputation: 247670
To SELECT
a value with it you can use:
select concat(left(col, 8), 'N ', substring(col, 9))
from table1
If you want to UPDATE
you can use:
update table1
set col = concat(left(col, 8), 'N ', substring(col, 9))
Upvotes: 1