SQL Wildcard

SQL Wildcard

In this article, SQL Wildcard, They are used just as LIKE operator, and also WHERE clause to search for a mere option in a column, The wildcard in SQL is used in a string to substitute characters.

Wildcard are two types:

1. Underscore (_)--> This wildcard is used to match the character.

2. Percent sign (%) --> This wildcard is used for matches in one or more characters.

 

Syntax

 

SELECT FROM table_name
WHERE column LIKE 'AAAA%'
SELECT FROM table_name
WHERE column LIKE '%AAAA%'

or

SELECT FROM table_name
WHERE column LIKE 'AAAA_'

or

SELECT FROM table_name
WHERE column LIKE '_AAAA'

or

SELECT FROM table_name
WHERE column LIKE '_AAAA_'

Example:

SELECT * FROM CUSTOMER
WHERE SALARY LIKE '2200%'
SELECT * FROM Customer
WHERE City LIKE 'de%'
SELECT * FROM Customer
WHERE City LIKE '%ee%'
SELECT * FROM Customer
WHERE City LIKE '_del'

 

 

2020-04-26