Suppose I have 400 lines of names of people in a database. What is the best way to search for their names?

They will also search for part of their name. Not just words with spaces. If they type Matt, I also expect to get Matthew.

+3
source share
4 answers
SELECT * 
FROM mytable 
WHERE name LIKE 'matt%' OR name LIKE '[ ,-/]matt%'

:
1) . , LIKE "% xyz%", , xyz . , " " "".
, . [^A-Z0-9] ( O'Brian brian, , , ...)

2) .. , , , . !
( 30 ), name. - , , , , ..
, SELECT * myTable [ "" ], , .
, , 50 000 (, , "" 40 ), : "" .

3) . , , , ( / ), .
, ( , , ..). , , - Soundex Soundex , , (, Wilmson vs. Wilmsen vs. Willmsonn ...)

+12

:

SELECT * 
 FROM mytable 
WHERE name LIKE '%matt%'
+10

:

... in that order of preference.

+1
source

If you are trying to find names through any development language, you can use the regular expression package in Java. Some things like java.util.regex. *;

0
source

Source: https://habr.com/ru/post/1735758/


All Articles