Currently I remove all non numeric characters and spacing using the following nested REPLACE
function. This enables me to compare a telephone number on the database without worrying if the telephone number has been entered containing non numeric values
SQL Example:
SELECT * FROM myTable
WHERE replace( replace( replace( replace( replace( TelephoneCol, ' ', '' ), '-', '' ), '(', '' ), ')', '' ), '+', '') = '01254566876'
The above query works perfectly and will find a match if there's a telephone number in the database which is formatted like (0) 1254566876
. The problem is that it's very slow. Is there a REGEX
or a better way of selecting a value from the database with all non numeric characters removed?
I'm using a custom PDO function that I parse an sql
string into. I am not using deprecated mysql functions.