Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the ways of Mysql fuzzy query

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

I do not know if you have any understanding of the articles similar to Mysql fuzzy query, today I am here to give you a brief introduction. If you are interested, let's take a look at the text. I believe you will gain something after reading the Mysql fuzzy query.

Summarize some things that have been used in the fuzzy query function in the development process, and that is, when you build a table, you must consider improving the table under construction, otherwise it will be very troublesome to change the table with a large amount of data in the later stage. please do not create it in a hurry in order to be able to use the table as soon as possible. I'm here to warn myself that I won't do it again. # select field from table where query field like'% query content%'; select detailcontent from detail_htmlinfo where detail_htmlinfo like'% Liu%'; SQL fuzzy query, when using like fuzzy query, add wildcards in SQL, you can refer to the following: 1.%: indicates any 0 or more characters. Characters of any type and length can be matched. In some cases, if it is in Chinese, please use two percent signs (%%). 2. _: represents any single character. Matches a single arbitrary character, which is often used to limit the character length statement of an expression. 3. []: represents one of the characters listed in parentheses (similar to a regular expression). Specify a character, string, or range that requires the matching object to be any one of them. 4. [^]: represents a single character that is not listed in parentheses. Its value is the same as [], but it requires that the matching object be any character other than the specified character. 5. When the query content contains wildcards, because of the wildcards, the statements of the special characters "%", "_" and "[" can not be implemented normally, but the special characters can be queried normally by using "[]". Full-text index query # SELECT field FROM table WHERE MATCH (query field) AGAINST ('query content'); SELECT detailcontent FROM detail_htmlinfo WHERE MATCH (detailcontent) AGAINST ('Liu' IN BOOLEAN MODE); note that the fields in MATCH (detailcontent) must be the full-text index previously established. The query content is case-insensitive AGAINST ('+ a-b'IN BOOLEAN MODE); + means AND, that is, it must be included. -indicates NOT, that is, it does not contain. AGAINST ('a b' IN BOOLEAN MODE); there is a space between an and b, and the space represents OR, which contains at least one of an and b. # SELECT field FROM table WHERE CONTAINS (query field, 'query content') SELECT detailcontent FROM detail_htmlinfo WHERE CONTAINS (detailcontent,'* Liu *')

The first one in CONTAINS (detailcontent) is the query field, and you want to create a full-text index.

What are the ways of reading Mysql fuzzy query? what do you think of this article? If you want to know more about it, you can continue to follow our industry information section.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report