Mysql uses instr for fuzzy query, instr fuzzy query
Using the internal function instr in mysql can replace the traditional like query method, and the query speed is faster.
Instr function. The first parameter is a field, and the second parameter is the string to be queried. The position of the returned string is 1. If it is not found, it is 0.
For example, to query the name of a field with "Jun", the traditional method is:
Select name from user table where name like '% Jun % ';
Using instr:
Select name from user table where instr ('name', 'june ');
Or:
Select name from user table where instr ('name', 'june')> 0;
Table
Field: Name
Zhang San
Wang Wu
Table B
Field: title
Information Released
Information II Wang Wu released
Information 3-3 release
Ranking list, sorted by the number of entries in table A's name like % 'name' % matching the title of table B,
Select name, count (B. title) from a inner join B on instr (B. title, a. Name)> 0 group by name order by count (B. title)
Summary
The above is all about how to use instr for fuzzy search in mysql. I hope it will be helpful to you. If you are interested, you can continue to refer to this site: explain the meaning of N and m in the MySQL Data Type DECIMAL (N, M), and analyze the differences between FIND_IN_SET () and IN, if you have any questions, you can leave a message at any time. The editor will reply to you in a timely manner. Thank you for your support!