Skip to content

Instantly share code, notes, and snippets.

@ViktorNova
Created November 7, 2015 00:05
Show Gist options
  • Save ViktorNova/9ad2b52daa6b6ec020cb to your computer and use it in GitHub Desktop.
Save ViktorNova/9ad2b52daa6b6ec020cb to your computer and use it in GitHub Desktop.
MySQL - Remove hyphens from phone numbers (Asteridex, find & replace)
In this example, user1 is the table name, out is the field name.
I'm removing hyphens from phone numbers.
Note the mysql names have `backticks` around them while the text fields have 'single quotes' around them.
MySQL:
````
update `user1`
set `out` = replace(`out`, '-', '');
````
PHP:
````
$sql = "update `user1`\n"
. "set `out` = replace(`out`, \'-\', \'\')";
````
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment