String Operations
There are the two string operators:
Percent (%) : This Operator (%) matches any substring.
Underscore ( _ ) : This Operator ( _ ) matches any character.
Example 1 :
- a) ‘Intro%’ matches any word beginning with ‘intro’.
- b) ‘%comp%’ matches any string containing ‘comp’ as a substring where before ‘comp’ and after ‘comp’, there can be other substrings.
- c) ‘%map’ matches any string where the last characters are ‘map’.
- d) ‘ab%yz’ matches any string where the first two characters are ‘ab’ and the last characters are ‘yz’.
- e) ‘_ _ _’ matches exactly with three characters.
- f) ‘_ _ _ %’ matches any string with at least three characters.
Example 2 : Write an SQL query to match cust-name from cust relation where the first four characters are ‘abcd’.
Select cust-name
from cust
wherecust-name like ‘abcd%’ ;
String Operations