E
E
entermix2015-07-09 13:09:32
MySQL
entermix, 2015-07-09 13:09:32

How to search by phone number?

The phone number in the database is stored in the format: +7(111)111-11-11
How can we implement a search for this number if we have such a +7(111)111-1111, or such a number: +71111111111 ? Preferably using regular expressions in SQL query

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Serykh, 2015-07-09
@vserykh

Regular expressions give a large overhead (excessive cost) with each search.
Why do you need this?
When saving to the database, bring the phone number to a single format (regular expressions are also possible), and then look for it without any problems.

M
myfirepukan, 2015-07-09
@myfirepukan

I will support Vladimir, when entering into the database, always bring the number to one format, when searching, first with regular expressions, bring it to the desired format, and only then a simple sql search query.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question