How to perform string matching with the SQL Like operator

Web developer can use the SQL Like operator to perform partial string matching to filter records where a particular field starts with, end with, or contains a certain sets of characters. For example, if Web developer wants to see all store applicants names that start with C, he/she could use the following statement:

SELECT * FROM Applicants WHERE appl_fname LIKE ‘C%’

To see a list of all names ending with M, he/she should put the present sign before the M, like this:

SELECT * FROM Applicants WHERE appl_fname LIKE ‘%M’

The third way to use the Like operator is to return any records that contains a certain character or sequence of characters. For example, if Web developer wants to see that names have the word ete somewhere in the name, he/she could use a SQL statement like this:

SELECT * FROM Applicants WHERE appl_fname LIKE ‘%ete%’

By default, SQL is not case sensitive, so this syntax finds instances of ETE, ete, or any variation of mixed case.

Finally, Web developer can indicate one of a set of characters, rather than just any character, by listing the allowed characters within square brackets. Here’s an example:

SELECT * FROM Applicants WHERE appl_fname LIKE ‘[efgh]%’

This SQL statement will return stores with names starting with E, F, G, or H.