SQL basic operations-wildcard characters

Source: Internet
Author: User

SQL wildcard: SQL wildcard can override one or more characters when searching for data in a database. SQL wildcard characters must be used with the LIKE operator. In SQL, you can use the following wildcard characters:

Wildcard characters Describe
% Override one or more characters
_ Replaces only one character
[Charlist] Any single character of the word columns
[^charlist] or [!charlist] Any single character that is not in the word columns

--The "Persons" table selects people living in a city that starts with "Ne"SELECT *  fromPersonsWHERECity like 'ne%'--The "Persons" table selects people living in cities that contain "Lond "SELECT *  fromPersonsWHERECity like '%lond%'--The person whose first character in the "Persons" table is followed by "Eorge "SELECT *  fromPersonsWHEREFirstName like '_eorge'--The last name of the record selected in the "Persons" table starts with "C", then an arbitrary character, then "R", then any character, then "ER"SELECT *  fromPersonsWHERELastName like 'C_r_er'--The "Persons" table selects people who live in cities that start with "A" or "L" or "N"SELECT *  fromPersonsWHERECity like '[aln]%--"Persons" table select people who live in cities that do not start with "A" or "L" or "N" select * from Persons' [! ALN]%'--The query is a name that begins with a three-word select * from tblstudent where tsname like'Single%'and LEN (tsname) =3

Reference: SQL wildcard characters

SQL basic operations-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.