String operator like
28. March 2009 15:16
The
Like operator implements pattern matching for strings of character data.
The
operator requires two parameters: a string expression to be searched and a
string pattern to search for.
The
string pattern may contain specific characters, as well as the following
wildcards:
%= zero
or more character positions
_= one
character position
String
pattern examples:
LIKE
‘IRE%’ – begins with ‘IRE’
LIKE
‘%IRE%’ - contains ‘IRE’ anywhere
Like
‘_IRE’ – contains IRE in the last three positions
LIKE
‘%I_’ – contains I in the next to last position
Select first_name,
last_name
From
customers
Where
last_name like ALL (‘%K%’,’%J%’)
Quantifiers:
ANY = any
single condition must be met (or)
SOME =
same as any
ALL = all conditions must be met (and)
LIKE with
ESCAPE character.
The ESCAPE
feature of LIKE permits wildcard characters to be treated as non-wildcards.
Characters
following the escape character are not treated as wildcards.
Example
Select
campaign_name
From
customers
Where
campaign_name like ‘_H_%’ escape ‘H’
Campaign_name
A_new_year
B_new_client
A_saving_account_805

Email 