SQL like wildcard []% instance Tutorial

Source: Internet
Author: User

Note: Mysql,sql Server,dbms and so on like wildcard characters do not support Text,ntext support only

Char,varchar,nvarchar, wait.

$s = "SELECT * from Test where dmulplace like '% $city% '"
ID UID parttime City
211 7117 Full-time Changsha, Yiyang
5510 12419 Full-time
5511 12420 Full-time Dongguan,
209 7115 Full-time Changsha

Results recorded in two

211 7117 Full-time Changsha
209 7115 Full-time Changsha

Here's a look at the simple SQL like wildcard description
_ and any single character match

% matches a string that contains one or more characters

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

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


Use the like comparison word, plus the wildcard characters in SQL, refer to the following:
A.. like ' mc% ' will search for all strings (such as McBadden) that begin with the letter Mc.

B.. like '%inger ' will search for all strings ending with the letter inger (such as Ringer,
Stringer).

C. Like '%en% ' will search all strings containing the letter en in any location (such as Bennet,
Green, McBadden).

D. Like ' _heryl ' will search for all six-letter names ending with the letter heryl (such as Cheryl,
Sheryl).

E. Like ' [Ck]ars[eo]n ' will search for the following strings: Carsen, Karsen, Carson, and Karson
(such as Carson).

F. Like ' [M-z]inger ' will search for any single word that ends with a string inger, from M to Z
All names (such as Ringer) that begin with the parent.

G.. like ' m[^c]% ' will search begins with the letter M, and the second letter is not all the names of C (for example,
Macfeather).

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.