Home > database >  MYSQL for a similar search engine search statement?
MYSQL for a similar search engine search statement?

Time:10-05

Requirement: there is A field A (VARCHAR), the front desk to string aa, use the aa to fuzzy matching, according to the similarity sorting, SQL should be how to write?


CodePudding user response:

https://zhidao.baidu.com/question/163677345.html

CodePudding user response:

https://zhidao.baidu.com/question/163677345.html

CodePudding user response:

The following SQL to be able to solve the basic problem, but the dog how to intercept this string as: dog, do, og, g.o?
SELECT *
The FROM (SELECT *,
CASE
The WHEN words LIKE '% % dog THEN
1
The WHEN words LIKE '% og %' THEN
2
The WHEN words LIKE '% g %' THEN
3
The WHEN words LIKE '% o %' THEN
4
END AS an rn
FROM the test
Dog WHERE words LIKE '% %'
Og the OR words LIKE '% %'
OR words LIKE '% g %'
OR words LIKE '% o %) AS k
The ORDER BY rn);
  • Related