You are currently viewing SQL LIKE Operator

SQL LIKE Operator

In this lesson we are working with the following student table

SQL LIKE Operator

LIKE Operator finds data from a column based on a specified pattern

Following example finds students’ first names which end with the letter ‘a ’

SELECT FirstName,LastName, state FROM student
WHERE FirstName LIKE '%a'

The output of the above query will be shown as follows

Following example finds students’ names that include ‘ca’ in their first name

SELECT FirstName,LastName, state FROM student
WHERE FirstName LIKE '%ca%’

The output of the above query will be shown as follows

SQL NOT LIKE Operator

NOT LIKE Operator is the opposite of the LIKE Operator

Following example finds students’ names without ‘ca’ in their first name

SELECT FirstName,LastName, state FROM student
WHERE FirstName NOT LIKE '%ca%'

The output of the above query will be shown as follows

Leave a Reply