Answer the question
In order to leave comments, you need to log in
MySQL: How to group data by field?
Good afternoon!
There is a table with data on orders, it contains the Phone field. It is necessary to extract information on orders and group them by this field, but there is one BUT: users entered the phone without an input mask, so the following entries occur:
79102222222
89102222222
9102222222
The phone of the same client, but he wrote it down differently. How in this case to take into account a different set of characters and combine the orders of this client?
There are other numbers in the field, landlines, not only cell phones.
Answer the question
In order to leave comments, you need to log in
1) Take the last N digits?
2) Or replace on the fly in mysql:
if there are 10 digits, then add 7 at the beginning or if the digit is different from 7 or 8.
If the digit is 8 at the beginning, then change it to 7
I think this will be enough to make the correct selection. Then, if there are additional conditions, add them to the code
3) validate when entering, placing an order for a phone. Put it on the manager.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question