• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 420
  • Last Modified:

MySQL script to strip out non numeric

Hi,

I have a column with telephone numbers where some fools have put in text and () insdie here. I need a script which I can run that will strip all this rubbish out. I will then need to put this script in a cron job...

Thanks
0
andybrooke
Asked:
andybrooke
  • 3
1 Solution
 
Swadhin RaySenior Technical Engineer Commented:
0
 
Swadhin RaySenior Technical Engineer Commented:
let us know if you need any more clarification
0
 
andybrookeAuthor Commented:
Will this clean the data? OR just select the data?
0
 
Swadhin RaySenior Technical Engineer Commented:
No cleanup just select and return .
instead of passing a sting you can pass the column name but if you want then you can use replacing too like :

## Selecting data

SELECT select uExtractNumberFromString(columnname) FROM table_name WHERE condition;

## For replacing
UPDATE table_name
SET columname = uExtractNumberFromString(columnname);

for updating entire table and for updating columns based on condition then

UPDATE table_name
SET columname = uExtractNumberFromString(columnname)
WHERE condition;
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

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