mysql concatenate question

Dear Experts,

I select the mobile phone numbers from my database where the length of the mobile number is one missing.
SELECT * FROM `mytable` WHERE length(mobile)='10'

the mobile numbers are supposed to be 11 characters, however I have 170 mobile number's length is 10, starting without 0

what I need to do is to select these 170 numbers and concatenate with 0

how can I do that with mysql?
LVL 1
BRMarketingAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
tried use concat function?

like:

SELECT a.*, concat('0', mobile) newValue  FROM `mytable` a WHERE length(a.mobile)=10

Open in new window


to do the update if above is working fine:

Update `mytable` set mobile = concat('0', mobile) where length(a.mobile)=10

Open in new window


CONCAT(str1,str2,...)
https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_concat
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Pawan KumarDatabase ExpertCommented:
>>what I need to do is to select these 170 numbers and concatenate with 0

To select this data.

SELECT *
From yourtable
Where len(concat('0', mobile))=11

To update..use below


Update yourtable
Set mobile = concat('0', mobile)
Where len(concat('0', mobile))=11
1
BRMarketingAuthor Commented:
thank you both
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.