Link to home
Start Free TrialLog in
Avatar of Steve Samson
Steve Samson

asked on

remove all non-numeric characters FROM A COLUMN?

How would I query a field and remove all non-numeric characters and then put the new data back in the field?
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Hi.

This may be helpful: https://www.experts-exchange.com/Programming/Languages/SQL_Syntax/A_252-How-to-Mimic-the-T-SQL-IsNumeric-Function-in-MySQL.html
In my Article, I talk about checking for isnumeric using regular expressions.  You can use this as part of a routine that pulls each character in ensures it is numeric to determine if it should remain in the string.  I have an example of this approach, but trying to think of more efficient ways to do this for you.

To assist with that, what is the pattern of the data, i.e., is it consistent with number value possibly at beginning or end?
Can you post a sample of data and expected results for each?
Please clarify non-numeric to determine if includes '.' that may pass the isnumeric test, i.e., see my isinteger function in Article.
ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve Samson
Steve Samson

ASKER

for exacmple i might have a phone number (580)555-1212 i want it to be 5805551212
or i have a value agc1234 and i want it to be 1234or agc1234a i want it to be 1234
Okay, so it can be varying patterns.  See my suggestion here then: http:#a35750560
The choice of IsNumeric versus IsInteger or some other REGEXP is how $25.50 should be treated.  Sounds like it should result in 2550, but in a pure IsNumeric check 25.50 or $25.50 is valid ... that is why I introduced IsInteger in my article as a bonus for those times when numeric means 0-9 only.
cleared my issue up