|
The LIKE Condition |
| |
The LIKE condition is used to specify a search for a pattern in a column. |
|
Syntax |
| |
SELECT column FROM table
WHERE column LIKE pattern |
|
| |
A "%" sign can be used to define wildcards (missing letters in the pattern) both before and after the pattern. |
| |
Using LIKE |
| |
The following SQL statement will return persons with first names that start with an 'K': |
| |
SELECT * FROM Persons
WHERE FirstName LIKE 'K%' |
|
| |
The following SQL statement will return persons with first names that end with an 'a': |
| |
SELECT * FROM Persons
WHERE FirstName LIKE '%a' |
|
| |
The following SQL statement will return persons with first names that contain the pattern 'la': |
| |
SELECT * FROM Persons
WHERE FirstName LIKE '%a' |
|
| |
The following SQL statement will return persons with first names that contain the pattern 'la': |
| |
SELECT * FROM Persons
WHERE FirstName LIKE '%la%' |
|
| |
| |
| |
| |