Wednesday, December 7, 2011

Oracle Tip : Multiple Like Conditions

I had a scenario for searching employee details based on comma seperated keywords entered by user.
I was searching for something that can solve my scenario in a single like condition and luckily I found "REGEX_LIKE"

REGEXP_LIKE is similar to the LIKE condition, except REGEXP_LIKE performs regular expression matching instead of the simple pattern matching performed by LIKE. This condition evaluates strings using characters as defined by the input character set.

Syntax of REGEXP_LIKE is  REGEXP_LIKE(sourcestring, pattern, matchparameter)
  • sourcestring is a character expression that serves as the search value
  • pattern is a regular expression
  • matchparameter is a text literal that lets you change the default matching behavior of the function eg. "i" for case insensitive, "c" for case sensitive etc.
For Eg. If I want to Select all the employees whose name starts with AB, SI, RO then

Select * from Employee where REGEXP_LIKE (Emp_Name ,'^(AB|SI|RO)','i');
 
If you would like to explore more Please Click Here

Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

0 comments : on " Oracle Tip : Multiple Like Conditions "