"_" wildcard characters in SQL

Source: Internet
Author: User

The "_" wildcard function is basically the same as the "%" wildcard, except that it only represents the match of any one word Fu, and of course, to indicate a match of two characters, you need to use two "_" wildcard characters,

The "_" is used only if the user determines the number of strings to query, but does not determine the exact value of one or more of the characters.

Example: Using the "_" wildcard to query a course with a class name of 5 words and start with "computer"

In the course table, for information about the names (CNAME), number of people (Scount), and time of Exam (ctest) for all courses that begin with "computer" and have only 5 words

Select Cname,scount,ctest from course where cname like ' computer _ ' ORDER by CNAME

2:

Similar to the "%" wildcard, the "_" wildcard can be used anywhere in the string, and, of course, the "_" wildcard can be used if the user knows only the number of strings to query and not the character of any of them.

Instance:

Use the "_" wildcard to query all courses with a course name of 6 words

In the course table, all courses named 6 characters are queried for the course name (CNAME), the number of people (Scount), and the time of the exam (ctest) information. Instance code:

Select CNAME, scount,ctest from course where cname like ' ___ ' ORDER by CNAME

At this point, it will be found that not only the course name 6 words of all courses, and the course name is less than 6 words of the record is included in the query results table, which is also in the actual application will be ignored, such as the query string "Computer _", if there is a record as "computer", it is also considered to be eligible so the

Select CNAME, scount,ctest from course where cname like ' ____ ' not cname like ' ___ ' ORDER by CNAME

"_" wildcard characters in SQL

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.