This is Anna's Blog

SQL: LIKE

The SQL LIKE Operator

  1. The LIKE operator is used to search for a specified pattern in a column.

  2. The LIKE condition is used in the WHERE clause of a SELECT, INSERT, UPDATE, or DELETE statement.

  3. The LIKE operator uses wildcard characters. A wildcard character is used to substitute one or more characters in a string. All the wildcards can also be used in combinations.

Wildcard Characters in SQL Server:

a) %

Represents zero or more characters

Example:

bl% finds bl, black, blue, and blob

b) _

Represents a single character

Example:

h_t finds hot, hat, and hit

c) []

Represents any single character within the brackets

Example:

h[oa]t finds hot and hat, but not hit

d) ^

Represents any character not in the brackets

Example:

h[^oa]t finds hit, but not hot and hat

e) -

Represents any single character within the specified range

Example:

c[a-b]t finds cat and cbt

Source:

https://www.w3schools.com/sql/sql_wildcards.asp

https://www.techonthenet.com/sql/like.php