Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I would like to append some data to already existing data, something like 720967537 to 255720967537. All the data in my column is in that format. Is there any way I can do that to all of the records that are in my MySQL database?

share|improve this question

1 Answer

up vote 2 down vote accepted

You can use the CONCAT() function:

select concat(255, 720967537), concat('my ', 'test')

Results:

255720967537, my test

SQL Fiddle with Demo

If you want to UPDATE the values in your table, you could do the following:

update t
set col1 = concat(255, col1)
  , col2 = concat('my ', col2);

See SQL Fiddle with Demo

share|improve this answer
Thank you @bluefeet how do i make that iterate through my whole column – Sitati Jul 26 '12 at 13:15
are you concatenating the same value to each row? If so then you will just apply the concat() on the table, similar to the SQL Fiddle – bluefeet Jul 26 '12 at 13:16
thank you @bluefeet it worked thank you so much – Sitati Jul 26 '12 at 13:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.