Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove hyphens using MySQL UPDATE? [duplicate]

Tags:

sql

mysql

Possible Duplicate:
How can I use mySQL replace() to replace strings in multiple records?
MySQL search to ignore hyphens

What is the best way to remove hyphens from a field using mysql UPDATE without php?

field: 211-555-1212 > 2115551212
like image 825
chrisrth Avatar asked Oct 23 '12 16:10

chrisrth


1 Answers

You can use the REPLACE() function, for UPDATE

UPDATE yourtable
SET field = replace(field, '-', '')

See SQL Fiddle With Demo

For SELECT:

SELECT replace(field, '-', '') field
FROM yourtable
like image 61
Taryn Avatar answered Oct 11 '22 20:10

Taryn