Where LIKE
The LIKE operator is used in a WHERE clause to search for a specific character pattern (text, numeric, date, mix, etc) in a column.
Where LIKE is often used when only a segment of the data item is known.
Where LIKE uses two wildcard match options the percent and underscore sign:
% The percent sign represents zero, one, or multiple characters
_ The underscore represents a single character
SQL Where LIKE syntax:
SELECT Column1, Column2, Column3
FROM Table_Name
Where Column1 LIKE 'Ta%’
Example:
Lets use the “Customers” Table to find all customers with the last name beginning with “j”.
Results:
Lets use the LIKE Statement to return all zip codes that contain the number “1”.
Results:
Sample LIKE combinations:
LIKE ‘z%’ - Finds any value(s) that start with “z”
LIKE ‘%z’ - Finds any value(s) that end with “z”
LIKE ‘%z%’ - Finds any value(s) that have “z” in any position
LIKE ‘z__%’ - Finds any value(s) that start with “z” and are at least 2 characters in length
LIKE ‘a%z’ - Finds any value(s) that start with “a” and ends with “z”
LIKE ‘_z% - Finds any value(s) that have “z” in the second position
SQL Tutorial