MySQL like wildcard character

Source: Internet
Author: User

I'm in MySQL right now. To write a query statement to query the name attribute in the Customer table that contains% (percent semicolon) a query that the master told how to write thank you urgently!!!

For example: SELECT * from customer where name like ' King% ';


MySQL like statement wildcard
MySQL provides standard SQL pattern matching and a format for extending regular expression pattern matching based on Unix utilities like VI, grep, and sed.

_ represents one character, and% is 0 to any character

If your query statement contains% of this special character, then/% or [%] can

Play the role of an escape character

Like ' 5[%] ' means 5%

Like ' 5% ' means 5 followed by more than 0 more characters

Like ' [_]h ' denotes-n

Like ' _n ' means an,bn,on (and so on)

Like ' [A-CDF] ' means a, B, C, D, or F

Like ' [-ACDF] ' means-, a, C, D, or F

Like ' [[] ' means [

Like '] ' says

Second, the example description:

Look in the table Personalmember to find records in the Strloginname field that contain "[".


You can use three statements:
1,
Select strloginname,* from Personalmember where strloginname like '%[% ' escape '

2, (description "" and "/" can be combined with the escape keyword as an escape character)
Select strloginname,* from Personalmember where strloginname like '%/[% ' escape '/'

3,
Select strloginname,* from dbo. Personalmember where CHARINDEX (' [', Strloginname) >0
---------------------------
Microsoft Internet Explorer--------------------------

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.