Hello Friends, Welcome to this post where I will be discussing about the SQL LIKE and NOT LIKE operator, the LIKE and NOT LIKE operator works wildcard characters.
Wildcard characters are a search criteria, where we use some symbol to match conditions, in SQL with LIKE we use the '%' symbol.
Lets look at an example, where our Table name is Employee.
PID Name Designation
222 Whiskey Moderator
444 Onty Admin
111 Gaurav Admin
333 Kumaar Admin
555 Rishabh Admin
666 Rose Admin
888 White Admin
999 Mikey Admin
Now check out the different LIKE query
1.
SELECT * FROM Employee
WHERE Name LIKE "Wh%"
This would display all the records for the Employees, whose name starts with "Wh"
2.
SELECT * FROM Employee
WHERE Name LIKE "%y"
This would display all the records for the Employees, whose name ends with "y"
3.
SELECT * FROM Employee
WHERE Name LIKE "%a%"
This would display all the records for the Employees, whose name has the letter "a" in it
4.
SELECT * FROM Employee
WHERE Name NOT LIKE "%a%
This would display all the records for the Employees, whose name does not contain the letter "a" in it.
So this is what I got for you in this post, hope you liked it, and Dont forget to check my next post.
Thank You!
Wildcard characters are a search criteria, where we use some symbol to match conditions, in SQL with LIKE we use the '%' symbol.
Lets look at an example, where our Table name is Employee.
PID Name Designation
222 Whiskey Moderator
444 Onty Admin
111 Gaurav Admin
333 Kumaar Admin
555 Rishabh Admin
666 Rose Admin
888 White Admin
999 Mikey Admin
Now check out the different LIKE query
1.
SELECT * FROM Employee
WHERE Name LIKE "Wh%"
This would display all the records for the Employees, whose name starts with "Wh"
2.
SELECT * FROM Employee
WHERE Name LIKE "%y"
This would display all the records for the Employees, whose name ends with "y"
3.
SELECT * FROM Employee
WHERE Name LIKE "%a%"
This would display all the records for the Employees, whose name has the letter "a" in it
4.
SELECT * FROM Employee
WHERE Name NOT LIKE "%a%
This would display all the records for the Employees, whose name does not contain the letter "a" in it.
So this is what I got for you in this post, hope you liked it, and Dont forget to check my next post.
Thank You!
0 comments:
Post a Comment