Home > Backend Development > PHP Tutorial > How to use the Like predicate that was ignored when writing it before_PHP Tutorial

How to use the Like predicate that was ignored when writing it before_PHP Tutorial

WBOY
Release: 2016-07-13 17:02:08
Original
796 people have browsed it

We know that the SELECT statement is used when writing queries using SQL statements. Its basic structure is as follows:
SELECT ... ... FROM ... ... WHERE ... ... ORDER BY ... ...
We know when using the WHERE conditional clause Fuzzy queries can be performed through the LIKE keyword, and we also know that wildcards can be used to achieve this. The wildcard characters we usually know are underscore_ and percent sign %. In fact, we have other query matching available, but we don't use them often and ignore them. What we ignored are matching a specific range [] and matching [^] outside the specific range.
Let’s take a look at the wildcards defined in Microsoft SQL Server:
Wildcard description

_ (underscore) matches any single character

% and contains one or more String matching of characters

[ ] matches any single character in a specific range (for example, [a-f]) or a specific set (for example, [abcdef]).

[^] matches any single character outside a specific range (for example, [^a-f]) or a specific set (for example, [^abcdef]).

Below we list some examples to illustrate the use of these wildcards.

WHERE FirstName LIKE '_im' finds all three-letter names ending in im (for example, Jim, Tim).
 


WHERE LastName LIKE '%stein' finds all employees whose last names end with stein.
 


WHERE LastName LIKE '%stein%' can find all employees whose last name includes stein anywhere.
 🎜>

WHERE FirstName LIKE '[JT]im' You can find three-letter names ending with im and starting with J or T (that is, only Jim and Tim)


WHERE LastName LIKE 'm[^c]%' can find all surnames starting with m and followed by (second) letter other than c.


http://www.bkjia.com/PHPjc/631095.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631095.htmlTechArticleWe know that the SELECT statement is used when writing queries using SQL statements. Its basic structure is as follows: SELECT ... ... FROM ... ... WHERE ... ... ORDER BY ... ... When using the WHERE conditional clause...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template