[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 449
  • Last Modified:

I am trying to clean some phone number that contain special characters such as ( ) - and any extra spaces in phone number fields.

I am trying to clean some phone number that contain special characters such as ( ) - and any extra spaces in phone number fields. How do I take out just digits from (548) 552-5254.
I am trying to get 5485525224.

Any ideas?
Thanks
0
martyje
Asked:
martyje
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you could replace all the characters that are "noise":


REPLACE(REPLACE(REPLACE(REPLACE(yourfield, ' ', ''), '-', ''), '(', ''), ')', '')

Open in new window

0
 
Leon TealePenetration TesterCommented:
what phone is it?

can you not 'edit' the contact or number?
0
 
martyjeAuthor Commented:
angelll:
Here's the query that I tried. What am I doing wrong here?
SELECT REPLACE( REPLACE( REPLACE( REPLACE(  `phone` ,  ' ',  '' ) ,  '-',  '' ) ,  '(',  '' ) ,  ')',  '' )

Thanks.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
UmeshMySQL Principle Technical Support EngineerCommented:
You are missing table name .



SELECT REPLACE(REPLACE(REPLACE(REPLACE(`phone` ,' ','' ) ,'-',''),'(','' ),')','') FROM tablename;
 
It seems `phone` is a column name..

Open in new window

0
 
martyjeAuthor Commented:
Sorry, should have asked the question differently. I want to update that change in the database permanently. All the phone numbers that I have in `phone` column, I want to take out all the special characters and spaces.
Thanks.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you will need to UPDATE, though:
0
 
martyjeAuthor Commented:
Thanks much
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now