O'Reilly logo

SQL: Visual QuickStart Guide by Chris Fehily

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extracting a Substring with SUBSTRING()

Use the SUBSTRING() function to extract part of a string. The SUBSTRING() function’s important characteristics are:

  • A substring is any sequence of contiguous characters from the source string, including an empty string or the entire source string itself.

  • SUBSTRING() extracts part of a string starting at a specified position and continuing for a specified number of characters.

  • A substring of an empty string is an empty string.

  • If any argument is null, SUBSTRING() returns null. (But see the Oracle exception in the DBMS Tip in this section.)

To extract a substring:

  • Type:
    SUBSTRING(string FROM start
    [FOR length])
    
    string is the source string from which to extract the substring. string is a string expression ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required