Recently, there is a need to find qualifying data based on the keywords in the search box.
If it is a single condition, it is actually a normal SELECT statement.
But the requirement is this keyword, to be in id,desc,step and so on multiple fields fuzzy lookup.
Then one of the most intuitive ideas must be:
Select * from where like % Key % or 'desclike%key%or like % Key %
For a record, the ID, DESC, step Three are judged that the character does not match the key.
Cons: The requirement is only three records, if it is multiple records, it will be very slow, and modify the statement is also very complex.
A better approach is to combine the fields that need fuzzy queries with concat to make a whole string, and then use like to match.
SELECT * from WHERE CONCAT ('desclike%key%
That's what I did in the project, and the mentor thought it was no big deal:
Do you have any better way, you can also exchange a bit of Kazakhstan.
MySQL multi-item fuzzy query