Hard Spocker Hard Spocker - 11 months ago 35
SQL Question

How do I modify/append a table row using MYSQL?

What I know is that you can append values from a query using concat function in MYSQL.

>col1 = ben

UPDATE table set col1 = concat(col1, ' altered')

>col1 = ben altered

But what I am trying to achieve is to append anywhere on the col.

col1 = ben

UPDATE table set col1 = "altered " + col1
-- pseudo code

col1 = altered ben

Is there a function for this in mysql?


If you want add before the column simply change the concat sequence

UPDATE table set col1 =  concat('altered ' , col1 )

You can se concat with all the column and value you prefer

 concat('altered ' , col1, ' altered')

 concat('altered ' , col1, ' altered', col2, col3, 'altered again')