Reputation: 1055
I have a mysql database column named like telephoneNo
Telephone No
25645656
45454545
45565656
I want to prepend two digits XX to every value of telephoneNo
column
Telephone No
xx25645656
xx45454545
xx45565656
I was trying to workout with concat but its not with integer values in my case please help with update query
Upvotes: 1
Views: 2779
Reputation: 3858
That's a hack change your col to varchar or something.
UPDATE table SET telephoneNo=9200000000+telephoneNo;
EDIT:
This method requires that all your numbers are of the same length, and 8 digits long, if all your numbers are more or less than 8 digits modify the number of 0's after the 92 accordingly
Upvotes: 1
Reputation: 77896
If your telephone
column is int, you can use concat
string function to concat with int
or string
even like below
SELECT CONCAT(xx, telephone);
(OR)
SELECT CONCAT('xx', telephone);
(OR)
Explicitly cast your int column value
SELECT CONCAT('xx', CAST(telephone AS CHAR));
Upvotes: 0