I have a database that grabs input from a website. The form on the website has poor validation so I get various types of entries for phone number. some of these formats.. 1 (222) 333-4444, 12223334444 1.222.333.4444 1/222/333/4444 .. you know... That Ol' chestnut!! I have even seen 1=222=333=4444 LOL ppl are crazy!
What I need to accomplish is, I need to build a query for my search engine that queries a = or LIKE phone.. I have one that works but there has to be a simple command I am missing that would replace my rediculous nest lol. My SELECT is as follows
Also could someone let me know how to insert code to this forum please?
SELECT * FROM contact WHERE (SELECT RIGHT(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(contact_prim_phone,"(",""),")", "" ), " ", "" ),"-",""),"+",""),10)) LIKE '$phone'
Like I said ... this seems to work fine but i am not sure if there is a quicker command to do it? like one that strips all non numeric chars, similar to the PHP
preg_replace("/[^0-9]/", "", $phone)
As it is i need to add lots more REPLACEs to cover all possible entries
Thank You
Mike
What I need to accomplish is, I need to build a query for my search engine that queries a = or LIKE phone.. I have one that works but there has to be a simple command I am missing that would replace my rediculous nest lol. My SELECT is as follows
Also could someone let me know how to insert code to this forum please?
SELECT * FROM contact WHERE (SELECT RIGHT(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(contact_prim_phone,"(",""),")", "" ), " ", "" ),"-",""),"+",""),10)) LIKE '$phone'
Like I said ... this seems to work fine but i am not sure if there is a quicker command to do it? like one that strips all non numeric chars, similar to the PHP
preg_replace("/[^0-9]/", "", $phone)
As it is i need to add lots more REPLACEs to cover all possible entries
Thank You
Mike