SUBSTRING(ansi)

From SQLZOO
Revision as of 12:02, 28 October 2012 by Peter (Talk | contribs)

Jump to: navigation, search
Compatibility
SUBSTRING(s FROM i FOR j)
EngineOKAlternative
ingresYesSUBSTRING(s,i,j)
mysqlYes
oracleNoSUBSTR(s,i,j)
postgresYesSUBSTRING(s,i,j)
sqlserverNoSUBSTRING(s,i,j)

SUBSTRING (ansi)

SUBSTRING allows you to extract part of a string.

   SUBSTRING('Hello world' FROM 2 FOR 3) -> 'llo'    

In this example you get the 2nd to 5th character from each country's name.

SELECT name,
       SUBSTRING(name, 2, 5)
  FROM bbc
SELECT name,
       SUBSTR(name, 2, 5)
  FROM bbc
SELECT name,
       SUBSTRING(name FROM 2 FOR 5)
  FROM bbc

See also

Language: English  • Deutsch
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense