Domesticated Brain

SQL LIKE Operator

 In this lesson we are working with following student table

SQL Tutorials LIKE Operator Student Table

 

SQL like Operator is used to filter data from a column based on specified pattern

Following example shows that we have filtered students with first name ending with the letter ‘ a ’

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

SQL Tutorials LIKE Operator Result 01

 

Following example show students with letter ‘ca’ in their first name

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

SQL Tutorials LIKE Operator Result 02

 

SQL NOT LIKE Operator

NOT LIKE Operator is the opposite of the LIKE Operator

Using following query NOT LIKE Operator is used to select students without letters ca in their first name

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

SQL Tutorials LIKE Operator Result 03

If you have found  what you expected please comment and like on our facebook page