sql tutorial

SQL Wildcard


  SQL > SQL Commands > Wildcard

There are times when we want to match on a string pattern. To do that, we will need to employ the concept of wildcard. In SQL, there are two wildcards:

% (percent sign) represents zero, one, or more characters.

_ (underscore) represents exactly one character.

Wildcards are used with the LIKE keyword in SQL.

Below are some wildcard examples:

• 'A_Z': All string that starts with 'A', another character, and end with 'Z'. For example, 'ABZ' and 'A2Z' would both satisfy the condition, while 'AKKZ' would not (because there are two characters between A and Z instead of one).

• 'ABC%': All strings that start with 'ABC'. For example, 'ABCD' and 'ABCABC' would both satisfy the condition.

• '%XYZ': All strings that end with 'XYZ'. For example, 'WXYZ' and 'ZZXYZ' would both satisfy the condition.

• '%AN%': All strings that contain the pattern 'AN' anywhere. For example, 'LOS ANGELES' and 'SAN FRANCISCO' would both satisfy the condition.

• '_AN%': All strings that contain a character, then 'AN', followed by anything else. For example, 'SAN FRANCISCO' would satisfy the condition, while 'LOS ANGELES' would not satisfy the condition.

SQL LIKE >>

Link to this page: If you find this page useful, we encourage you to link to this page. Simply copy and paste the code below to your website, blog, or profile.



Copyright 1999-2009 1keydata.com.   All Rights Reserved.     Privacy Policy  








SQL SELECT
SQL DISTINCT
SQL WHERE
SQL AND OR
SQL IN
SQL BETWEEN
SQL Wildcard
SQL LIKE
SQL ORDER BY
SQL Functions
SQL Average
SQL COUNT
SQL MAX
SQL MIN
SQL SUM
SQL GROUP BY
SQL HAVING
SQL ALIAS
SQL AS
SQL JOIN
SQL OUTER JOIN
SQL CONCATENATE
SQL SUBSTRING
SQL TRIM
SQL LENGTH
SQL REPLACE

SQL CREATE TABLE
SQL CONSTRAINT
SQL NOT NULL
SQL DEFAULT
SQL UNIQUE
SQL CHECK
SQL PRIMARY KEY
SQL FOREIGN KEY
SQL View
SQL CREATE VIEW
SQL Index
SQL CREATE INDEX
SQL ALTER TABLE
SQL DROP TABLE
SQL TRUNCATE TABLE
SQL USE
SQL INSERT INTO
SQL UPDATE
SQL DELETE FROM

SQL Jobs

Site Map
Resources



CSS Tutorial

PHP Tutorial

Data Warehousing & Business Intelligence