1

I have a MySQL table and want to add 'x' to the beginning of a column value for every row.

My syntax guess was:

UPDATE table1 SET col5='x'.col5

This did not work. Any ideas?

Teun Zengerink
  • 4,277
  • 5
  • 30
  • 32
David19801
  • 11,214
  • 25
  • 84
  • 127

4 Answers4

4
update table1 
set col5 = CONCAT('x', col5)
where col5 NOT LIKE 'x%'; -- optional, depending on circumstances
gbn
  • 422,506
  • 82
  • 585
  • 676
2
update table1 set col5 = 'x' + col5
juergen d
  • 201,996
  • 37
  • 293
  • 362
1
UPDATE table1 SET col5 = CONCAT('x', col5);
xdazz
  • 158,678
  • 38
  • 247
  • 274
1

You can also try MySQL CONCAT:

UPDATE table1 SET col5 = CONCAT('x',col5)
Community
  • 1
  • 1
Naveed
  • 41,517
  • 32
  • 98
  • 131