L
L
Leopandro2018-02-22 14:31:30
MySQL
Leopandro, 2018-02-22 14:31:30

How to solve the problem with such request?

I have a field (one) where the search text is entered (first name, last name and patronymic), and there are three columns in the table, first name, last name, middle name.
When searching for the name Ivan, Ivans, Ivanovs, Ivanovichs will be displayed.
And when searching for Aleksey Ivanov, all Alekseys and all Ivanovs and Ivanovichs will be displayed, how to make it look only for those lines in which there are both values ​​Aleksey and Ivanov. The difficulty is that we can get the search string Ivanovich Alexey, Alexey Ivanov, Ivanov Petrovich - i.e. the order may be different.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Leopandro, 2018-02-22
@Leopandro

Found solutions myself (sample query):

select id,pr.name,pr.surname,pr.patronymic from proposals pr
where CONCAT_WS(' ', pr.name, pr.surname, pr.patronymic) LIKE  '%Ив%Андре%'

A
Alexander, 2018-02-22
@alexr64

Tear apart the request for words and independently determine by morphological features or a dictionary where the name is and where the patronymic is.

A
Alex, 2018-02-22
@streetflush

Split into words and search for each word in each column via OR

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question