bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

SQL LIKE Keyword

Concept visual

SQL LIKE Keyword

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

LIKE Keyword

Previous

❮ SQL Keywords

Next

Like

The LIKE

command is used in a WHERE clause to search for a specified pattern in a column.

You can use two wildcards with

Like

% - Represents zero, one, or multiple characters

Formula

_ - Represents a single character (MS Access uses a question mark (?) instead)

The following SQL selects all customers with a CustomerName starting with "a":

Example

SELECT * FROM Customers
WHERE CustomerName LIKE 'a%';
The following SQL selects all customers with a CustomerName ending with "a":

Example

SELECT * FROM Customers
WHERE CustomerName LIKE '%a';
The following SQL selects all customers with a CustomerName that have "or" in any position:

Example

SELECT * FROM Customers
WHERE CustomerName LIKE '%or%';
The following SQL statement selects all customers with a CustomerName that starts with "a" and are at least 3 characters in length:

Example

SELECT * FROM Customers
WHERE CustomerName LIKE 'a__%';

Previous

❮ SQL Keywords

Next

Previous

SQL LEFT JOIN Keyword

Next

SQL SELECT TOP, LIMIT and ROWNUM Keywords