26

I have a field in the mysql database and I would like to insert text in front of all the values in that field.

I would like to add "F21 - " So the field would be "F21 - product name" instead of "product name"

I need a simple sql query

any ideas?

donL
  • 1,290
  • 3
  • 13
  • 37
Ivar
  • 786
  • 2
  • 11
  • 21
  • 1
    possible duplicate of http://stackoverflow.com/questions/680801/prepending-a-string-to-a-column-value-in-mysql – Shakti Singh Feb 24 '11 at 16:19
  • That question didn't have any of the search terms I used so I didn't find it. Thanks for posting. – Ivar Feb 24 '11 at 16:34

1 Answers1

64

Use CONCAT. Something like this:

UPDATE mytable SET myfield = CONCAT('f21 -', myfield)
Avatar
  • 14,622
  • 9
  • 119
  • 198
UltraInstinct
  • 43,308
  • 12
  • 81
  • 104