D
D
Dmitry2019-01-10 17:58:43
MySQL
Dmitry, 2019-01-10 17:58:43

How to write mysql query optimally?

The task is this, the database stores user data, we need to find all users by numbers, in total we have 26 thousand numbers for which we need to search. Now my request looks like this, but I think there is an easier way.

use test1;
SELECT `firstname`, 
`middlname`,
 `lastname`,
 `age`,
 `phone1`,
 `phone2`,
 `town`, 
 `desired_profession`,
 `email1`
 
FROM profil WHERE 

   `phone1` and `phone2` REGEXP '83519025115|
87051036787|
88142531260|
88236732850|
88237664692|
88528031558|
88658734843|
89000525888';

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2019-01-10
@good_br

WHERE 
(
    `phone1` IN ('83519025115','87051036787', '88142531260', ...) 
  OR
    `phone2` IN ('83519025115','87051036787', '88142531260', ...)
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question