sqlserver--Fuzzy query-wildcard characters

Source: Internet
Author: User

--Wildcard characters: _,%, [], ^

--_ denotes any single character

Surname Zhang, two words.

SELECT * from mystudent where fname like ' Zhang _ '

--surname Zhang, three words

SELECT * from mystudent where fname like ' Zhang __ '

--% matches any number of arbitrary characters

--regardless of the number of words, as long as the first character is ' Zhang ' on the query out

SELECT * from mystudent where fname like ' sheet% '

SELECT * from mystudent where fname like ' Zhang% ' and Len (fname) =2

--[] indicates the filter, scope.

SELECT * FROM Tblstudent

SELECT * from tblstudent where tsname like ' Zhang [0-9] sister '

SELECT * from tblstudent where tsname like ' Zhang _ Mei '

SELECT * from tblstudent where tsname like ' Zhang [a-z] sister '

SELECT * from tblstudent where tsname like ' Zhang [a-z0-9] sister '

SELECT * from tblstudent where tsname like ' Zhang [^0-9] sister '

SELECT * from Tblstudent where tsname don't like ' Zhang [0-9] sister '

Update tblstudent Set Tsname=replace (Tsname, ' (female) ', ')

--Check out the people whose names contain%

--The wildcard is not considered a wildcard if it is escaped in the [].

SELECT * from tblstudent where tsname like '%[%]% '

--where ColumnA like '%5/%% ' ESCAPE '/'

--Specify an escape character yourself

SELECT * from tblstudent where tsname like '%/]% ' ESCAPE '/'

SELECT * from tblstudent where tsname like '%/[% ' ESCAPE '/'

SELECT * from tblstudent where tsname like '%/[%/]% ' ESCAPE '/'

sqlserver--Fuzzy query-wildcard characters

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.