Difference between revisions of "SUBSTR"

From SQLZOO
Jump to: navigation, search
(Created page with "<table align='right' border='1'> <caption>Compatibility</caption> <tr><th colspan='3'>SUBSTRING(s FROM i FOR j)</th></tr> <tr><td align='center'>'''Engine'''</td><td align='ce...")
 
Line 17: Line 17:
 
<div class='ht'>
 
<div class='ht'>
 
In this example you put the region and the name together for each country.   
 
In this example you put the region and the name together for each country.   
<source lang='sql' class='def e-oracle e-sqlserver'>
+
<source lang='sql' class='def e-sqlserver'>
 
SELECT name,
 
SELECT name,
 
       SUBSTRING(name, 2, 5)
 
       SUBSTRING(name, 2, 5)

Revision as of 15:25, 16 July 2012

Compatibility
SUBSTRING(s FROM i FOR j)
EngineOKAlternative
ingresYesSUBSTRING(s FROM i FOR j)
oracleYes
postgresYesSUBSTRING(s FROM i FOR j)
sqlserverNoSUBSTRING(s,i,j)

SUBSTR

SUBSTR allows you to extract part of a string.

   SUBSTR('Hello world', 2, 3) -> 'llo'    

In this example you put the region and the name together for each country.

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