green
green

Reputation: 131

MySQL query - Add string before, after existing data

I was wondering if someone is able to lend some wisdom about how to accomplish the following task in MySQL.

I need to run a query to add something inside a field before and after the existing data. For example, let's say I have the following data in 'characters.name':

'Fred Flintstone'
'Barney Rubble'

How would I insert something, in this example 'xxxxx' before the existing data 'Fred Flinstone' and also 'yyyyy' after the data?

The result would be:

'xxxxxFred Flintstoneyyyyy'
'xxxxxBarney Rubbleyyyyy'

Any assistance with this would be greatly appreciated.

Many thanks!

Upvotes: 11

Views: 25326

Answers (1)

eggyal
eggyal

Reputation: 125865

SELECT CONCAT('xxxxx', name, 'yyyyy') AS name FROM characters

Upvotes: 25

Related Questions