Mysql like fuzzy search tutorial

Source: Internet
Author: User

SQL pattern matching allows you to use "_" to match any single character, while "%" matches any number of characters (including zero characters ). In MySQL, the SQL mode is case-insensitive by default. Some examples are shown below. Note that when you use SQL mode, you cannot use = or! =; And use the LIKE or not like comparison operator.

Mysql full-text search written in the previous article. Now let's look at SQL fuzzy search. We usually use %? *-To replace the search content

MySQL provides standard SQL mode matching and an extended regular expression mode matching format based on Unix utilities such as vi, grep, and sed.

SQL pattern matching allows you to use "_" to match any single character, while "%" matches any number of characters (including zero characters ). In MySQL, the SQL mode is case-insensitive by default. Some examples are shown below. Note that when you use SQL mode, you cannot use = or! =; And use the LIKE or not like comparison operator.

Let's take a look at an SQL like instance tutorial.

Select * from customer where name like 'wang % ';

Here is the name of the person whose name starts with Wang Kai.

"? "Or" _ "(underline) any single character
"*" Or "%" zero or multiple characters
"#" Any single number (0-9)
[Charlist] any single character in the orders table
[! Charlist] any single character not in the orders table
Note that only Microsoft®When Jet 4.X and Microsoft ole db Provider for Jet, ansi SQL wildcards (%) and (_) are available. If Microsoft Access or DAO is used, it is considered as a literal character.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.