Add value at the beginning and end of a mysql string

Asked

Viewed 113 times

1

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

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

1 answer

2


You can use the function CONCAT.

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

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

To add information afterward of current value:

UPDATE question_answer SET answer = CONCAT(answer, '</p>');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.