"MySQL is better than know." The eighth chapter is filtered with a wildcard character

Source: Internet
Author: User

1. Like operator

Previously used operators are for known data, and wildcard characters can also be used to search for unknown data.

wildcard character (wildcard): used to match Special characters that are worth a portion.

Search pattern: A search condition consisting of a literal value, a wildcard character, or a combination of both.

To use a wildcard character for a search clause, you must use the LIKE operator because it indicates MySQL, followed by a wildcard match instead of a direct equality match.

predicate: When an operator acts as a predicate, it is no longer an operator and like is a predicate.

2, percent semicolon wildcard character%

% indicates any number of occurrences of any character.

Input: SELECT prod_id,prod_name

From Products

WHERE prod_name like ' jet% ';

Analysis: Show two columns-Product ID and name, table source-products, filter terms the product name first three characters is jet (regardless of case, but the search mode can be set case-insensitive, not set here).

Note: Wildcards can appear anywhere in the search mode, the number is arbitrary, such as: Like '%jet% ', such as ' s%e ', wildcard characters in addition to one or more characters, can also match 0 characters, so the wildcard range is actually 0-∞. Wildcard characters cannot match null.

3, underline the wildcard character (_)

The underscore wildcard can match only one character.

4. Tips for using wildcard characters

Do not overuse wildcard characters, which are at the cost of performance.

Be sure to use a wildcard character, and do not place it at the beginning of the search pattern.

"MySQL is better than know." The eighth chapter is filtered with a wildcard 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.