Using the internal function instr in MySQL can replace the traditional like query method and is faster. The instr function takes the field as its first argument and the string to be queried as its second argument. It returns the position of the string. The first one is 1, and if it is not found, it is 0. For example, to query names with "军" in the field name, the traditional method is: select name from user table where name like `%军%'; Using the instr method: select name from user table where instr('name','军'); or: select name from user table where instr('name','军')>0; Table A Field: Name Zhang San Table B Field: title Information is published in three parts Ranking list, sort by the number of entries where the name like %'name'% in table A matches the title in 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) Summarize The above is all the content of this article about the use of instr for fuzzy query method in MySQL. I hope it will be helpful to everyone. Interested friends can continue to refer to this site: Detailed explanation of the meanings of N and M in the MySQL data type DECIMAL(N,M), a brief analysis of the differences between FIND_IN_SET() and IN in MySQL, etc. If you have any questions, you can leave a message at any time and the editor will reply to you in time. Thank you friends for supporting this site! You may also be interested in:
|
<<: Linux CentOS6.9 installation graphic tutorial under VMware
>>: How to install Maven automatically in Linux continuous integration
1. Download MySQL Log in to the MySQL official we...
This article uses an example to describe how MySQ...
After clicking the a tag in the page, you want to ...
Note: If there are any errors in the article, ple...
I just joined a new company recently. After getti...
Table of contents Some basic configuration About ...
Table of contents 1. Demo Project 1.1 Interface P...
1. Download the ElasticSearch 6.4.1 installation ...
Table of contents 1. Use the warehouse to create ...
Today, let's introduce several common text pr...
1. Go to Vim's official website to download t...
background As we all know, after we develop a Jav...
Preview address: https://ovsexia.gitee.io/leftfix...
This article shares the specific code of JavaScri...
When it comes to styling our web pages, we have t...