everydayapps
everydayapps

Reputation: 455

Update MySQL column in place

I have a column in my table as number of type varchar(15). This contains phone numbers. I would like to append a constant country code to each of the phone numbers. i.e if the number is 1234567890 I want it to be updated to 911234567890 where '91' is the country code. Is there a simple way to do this or do I have to run a loop through all the rows?

Upvotes: 1

Views: 1386

Answers (2)

Israr
Israr

Reputation: 162

try this:

UPDATE tablename SET number=concat('91',number);

Upvotes: 2

Sorin
Sorin

Reputation: 5415

UPDATE table SET number = CONCAT('91', number)

Upvotes: 3

Related Questions