[thelist] Regular Expression help (MySQL)

Mattias Thorslund mattias at thorslund.us
Sat Jul 5 02:17:06 CDT 2008


Rick den Haan wrote:
> WHERE REGEXP_REPLACE(`phone`, '[^0-9] ', '') LIKE '%678%'
>   

All I can tell you is that running a transformation on every record in 
your table for every search is not going to be very efficient. If you 
clean your data to a consistent format, you will be able to run the LIKE 
comparison easier. If nothing else, consider adding a column with the 
cleaned phone numbers to your table.

LIKE will probably not be able to use indexes well (especially not 
expressions that begin with a wildcard), but at least you don't have to 
transform your data every time.


Cheers,

Mattias



More information about the thelist mailing list