Add value at the beginning and end of a string in mysql

1

How to add text at the beginning and end of a string?

For example, I'd like to add <p style="display:inline;"> at start and </p> at the end of all rows in column answer in table question_answer .

    
asked by anonymous 20.04.2018 / 14:24

1 answer

2

You can use the CONCAT function.

To concatenate the before information of the current value, you can use:

UPDATE question_answer SET answer = CONCAT('<p style="display:inline;">', answer );

To add information after of the current value:

UPDATE question_answer SET answer = CONCAT(answer, '</p>');
    
20.04.2018 / 14:32