next up previous
Next: Ordering the Display of Up: Basic Structure Previous: Tuple Variables

String Operations

  1. The most commonly used operation on strings is pattern matching using the operator like.
  2. String matching operators % (any substring) and _ (underscore, matching any character).

    E.g., ``___%'' matches any string with at least 3 characters.

  3. Patterns are case sensitive, e.g., ``Jim" does not match ``jim".
  4. Use the keyword escape to define the escape character.

    E.g., like ``ab%tely tex2html_wrap_inline1742 % tex2html_wrap_inline1742 '' escape `` tex2html_wrap_inline1742 '' matches all the strings beginning with ``ab'' followed by a sequence of characters and then ``tely'' and then ``% tex2html_wrap_inline1742 ''.

    Backslash overrides the special meaning of these symbols.

  5. We can use not like for string mismatching.
  6. Example. Find all customers whose street includes the substring ``Main''.

     select cname
    

    from customer

    where street like ``%Main%''

  7. SQL also permits a variety of functions on character strings, such as concatenating (using `` tex2html_wrap_inline1750 ''), extracting substrings, finding the length of strings, converting between upper case and lower case, and so on.


Osmar Zaiane
Fri May 22 19:39:12 PDT 1998