LIKE comparison test operator

SELECT first_column_name, second_column_name
FROM table_name
WHERE first_column_name LIKE 'Mc%';

The LIKE pattern matching operator can also be used in the conditional selection of the where clause. Like is a very powerful character string comparison operator that allows you to select only rows that are “like” what you specify. The percent sign “%” can be used as a wild card to match any possible character that might appear before or after the characters specified. For example:

select first, last, city
from empinfo
where first LIKE 'Mc%';

This SQL statement will match any first names that start with ‘Mc’. Strings must be in single quotes.

Ready to go back to the lesson?