Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wrap (prefix & suffix) all values in a column with a string?

Tags:

mysql

I have a MySQL table with about 1000 rows in it.

id column
1  apple
2  banana
...
etc

I need a MySQL query (UpdatE) to wrap (prefix & suffix) all values in a column with a specific string, let's say "_", so I am expecting a result:

id column
1  _apple_
2  _banana_
...
etc

How to do that? Please, advice.

like image 992
Ken Avatar asked Aug 22 '09 08:08

Ken


1 Answers

update table
set column = concat('_', column, '_');
like image 178
Zed Avatar answered Nov 10 '22 03:11

Zed