E
E
Evgeny Startsev2018-05-04 12:37:42
MySQL
Evgeny Startsev, 2018-05-04 12:37:42

How to do the right search?

Good afternoon
The situation is this - there is an online store of nuts
. You need to finish the search to search by part of the word
. For example, the client enters "Cedar" in the search - the result is "nothing found"
But if you enter "cedars" - then everything finds the
Search code -

SELECT `name` FROM `table` WHERE `name` LIKE '%кедров%'

The question itself is whether it is possible in SQL to search by part of the entered word?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2018-05-04
@lebonnet

after all attempts to force MySQL to search normally fail, you will need to fasten sphinx

O
Oleg, 2018-05-04
@Austin_Powers

Probably a case issue.
Lowercase the word before searching and use the LOWER function in SQL.

SELECT `name` FROM `table` WHERE LOWER(`name`) LIKE '%кедров%'

P
Pavel Bykov, 2018-05-04
@mafof

Well, MB as an option, if the request did not return results, then you can write a method that, instead of the cedar one, will look for cedars, cedars, cedars, ... and the first match has not yet been found

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question