D
D
Dmitry2018-03-22 03:24:25
MySQL
Dmitry, 2018-03-22 03:24:25

regexp or like query, why different result?

Goodnight ! I am making a selection from the database, and I ran into a problem... I need a selection of doctors doctor (|doctor|therapist|Speech therapist|Mammologist, etc.) when I make a request using LIKE , I get a selection of more I do the same with regexp, how is it possible? And how to make a request, through regexp , that would display a large number?
both queries are written below.

use test1;
SELECT `firstname`,
`middlname`,
 `lastname`,
 `age`,
 `phone1`,
 `phone2`,
 `desired_profession`,
 `email1`
 `type_of_work`,
 `place_of_work`,
 `pol`,
 `birthday`,
 `birthmonth`,
 `birthyear`,
 `maritalstatus`,
 `children`,
 `best`,
 `dop`,
 `driving_licence`,
 `education`
FROM profil WHERE town =4 and
    

   `desired_profession` REGEXp  'врач|доктор|терапевт|Логопед|Маммолог
|Мануальный|Массажист|Миколог
|Нарколог
|Невролог
|Нейрохирург
|Неонатолог
|Нефролог
|Окулист
|офтальмолог
|Онкогинеколог
|Онкодерматолог
|Онколог
|Ортопед
|Остеопат
|Отоларинголог
|Педиатр
|Пластический хирург
|Подолог
|Проктолог
|Психиатр
|Психолог
|Психотерапевт
|Пульмонолог
|Реабилитолог
|Ревматолог
|Рентгенолог
|Репродуктолог
|Рефлексотерапевт
|Сексолог
|Семейный врач
|Сомнолог
|хирург
|Специалист по клеточным технологиям
|Сурдолог
|Терапевт
|Травматолог
|Трихолог
|УЗИ
|Уролог
|Физиотерапевт
|Флеболог
|Фтизиатр
|Хирург
|Эндокринолог
|Эндоскопист
|Эпилептологи';

Second request
use test1;
SELECT `firstname`,
`middlname`,
 `lastname`,
 `age`,
 `phone1`,
 `phone2`,
 `desired_profession`,
 `email1`
 `type_of_work`,
 `place_of_work`,
 `pol`,
 `birthday`,
 `birthmonth`,
 `birthyear`,
 `maritalstatus`,
 `children`,
 `best`,
 `dop`,
 `driving_licence`,
 `education`
FROM profil WHERE town =4 and

   `desired_profession`  LIKE "%врач%";

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Immortal_pony, 2018-03-22
@Immortal_pony

when I make a request with LIKE , I get a larger number of selections than I do the same with regexp, how is it?
Why do you think that you have the same mask? She is completely different.
The value for REGEXP is designed so that only exact matches are searched.
For example, if your "desired_profession" field has the value "physician", then it will fall under your LIKE condition, but will not fall under your regular expression.
But the value "doctor" will fall under both conditions.
REGEXP '.*врач.*'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question