Use LIKE to find matching strings and substrings
suggest changeSee full documentation on LIKE operator.
This example uses the Employees Table from the Example Databases.
SELECT *
FROM Employees
WHERE FName LIKE 'John'
This query will only return Employee #1 whose first name matches ‘John’ exactly.
SELECT *
FROM Employees
WHERE FName like 'John%'
Adding % allows you to search for a substring:
John%- will return any Employee whose name begins with ‘John’, followed by any amount of characters%John- will return any Employee whose name ends with ‘John’, proceeded by any amount of characters%John%- will return any Employee whose name contains ‘John’ anywhere within the value
In this case, the query will return Employee #2 whose name is ‘John’ as well as Employee #4 whose name is ‘Johnathon’.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents