Mysql like wildcard

Source: Internet
Author: User

I want to write a query statement in MYSQL to query the query statement containing % (percentage) in the name attribute in the customer table. Which of the following statements can I tell you how to write? Thank you for your urgent use !!!

Example: select * from customer where name like 'wang % ';


Mysql like statement wildcard
MySQL provides standard SQL mode matching and an extended regular expression mode matching format based on Unix utilities such as vi, grep, and sed.

_ Represents a character, while % Represents 0 to any character

If your query statement contains special characters such as %, either/% or [%] can be

Escape Character

Like '5 [%] 'indicates 5%

Like '5% 'indicates 5 followed by 0 and more characters

Like '[_] H' indicates-n

Like '_ n' indicates an, bn, on (and so on)

Like '[a-cdf]' indicates a, B, c, d, or f

Like '[-acdf]' indicates-, a, c, d, or f

Like '[[]' indicates [

Like ']' indicates]

Ii. instance description:

In the PersonalMember table, find the record containing "[" in the strloginname field.


Three statements are available:
1,
Select strloginname, * from PersonalMember where strloginname like '% [% 'escape''

2. (description "" and "/" can be combined with the escape keyword as escape characters)
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.