I would like to search in one outsource table, who has phone column, but in the database the phone numbers don’t have schema.
So the phone number is varchar and has lots of char (eg: ” “, -, +, /)
Do it mysql query what can like only numbers in varchar?
Example:
input: 30321321
Database:
+36-30/321 32-1
70/32132131
0630-32-13-21
My idea:
Select * from foo where phone like "%3%0%3%2%1%3%2%1%";
Just this is ugly and resource-intensive.
The database have 100000 rows and 2 phones columns.
Any better idea?
I would use
REGEXP… (I guess now I have two problems 🙂 )Try this:
SELECT * FROM foo WHERE phone REGEXP '3(.)?0(.)?3(.)?2(.)?1(.)?3(.)?2(.)?1'Note: This would ignore any indexed defined on the phone column, so take caution if running it against a table with lot of rows.