Friday, June 1, 2012

SQL LIKE Operator

The LIKE operator is used to search for a specified pattern in a column


SQL LIKE Syntax
SELECT column_names (s) FROM table_name
WHERE column_name LIKE pattern


LIKE Operator Example
SELECT * FROM Employee
WHERE EmpName LIKE 'S%'


*If the pattern is given as 'S%' then it will display all values start with S
*If the pattern is given as '%S' then it will display all values end with S
*If the pattern is given as '%CAS%' then it will display all values which contain the given word between the percentage symbol.


NOT LIKE Operator Example
SELECT * FROM Employee
WHERE EmpName NOT LIKE '%CAS%'


*If the pattern is given as '%CAS%' then it will display all values which does not contain the given word between the percentage symbol.


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.