Difference between revisions of "SUBSTRING"

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...")
 
(2 intermediate revisions by one user not shown)
Line 5: Line 5:
 
<tr><td align='left'>ingres</td><td>Yes</td><td>[[SUBSTRING(ansi) |SUBSTRING(s FROM i FOR j)]]</td></tr>
 
<tr><td align='left'>ingres</td><td>Yes</td><td>[[SUBSTRING(ansi) |SUBSTRING(s FROM i FOR j)]]</td></tr>
 
<tr><td align='left'>mysql</td><td>Yes</td><td>[[SUBSTRING(ansi) |SUBSTRING(s FROM i FOR j)]]</td></tr>
 
<tr><td align='left'>mysql</td><td>Yes</td><td>[[SUBSTRING(ansi) |SUBSTRING(s FROM i FOR j)]]</td></tr>
<tr><td align='left'>oracle</td><td>No</td><td>[[SUBSTR(s,i,j)]]</td></tr>
+
<tr><td align='left'>oracle</td><td>No</td><td>[[SUBSTR |SUBSTR(s,i,j)]]</td></tr>
 
<tr><td align='left'>postgres</td><td>Yes</td><td>[[SUBSTRING(ansi) |SUBSTRING(s FROM i FOR j)]]</td></tr>
 
<tr><td align='left'>postgres</td><td>Yes</td><td>[[SUBSTRING(ansi) |SUBSTRING(s FROM i FOR j)]]</td></tr>
 
<tr><td align='left'>sqlserver</td><td>Yes</td><td></td></tr>
 
<tr><td align='left'>sqlserver</td><td>Yes</td><td></td></tr>
 
</table>
 
</table>
<h1> SUBSTRING (ansi)</h1>
+
<h1> SUBSTRING</h1>
 
<p>SUBSTRING allows you to extract part of a string. </p>
 
<p>SUBSTRING allows you to extract part of a string. </p>
 
<p></p>  
 
<p></p>  
 
<pre style='width:75ex'>
 
<pre style='width:75ex'>
   SUBSTRING('Hello world' FROM 2 FOR 3) -> 'llo'     
+
   SUBSTRING('Hello world', 2, 3) -> 'llo'     
 
</pre>
 
</pre>
  
 
<div class='ht'>
 
<div class='ht'>
In this example you put the region and the name together for each country. 
 
 
 
<source lang='sql' class='def e-oracle'>
 
<source lang='sql' class='def e-oracle'>
 
SELECT name,
 
SELECT name,

Revision as of 16:26, 16 July 2012

Compatibility
SUBSTRING(s FROM i FOR j)
EngineOKAlternative
ingresYesSUBSTRING(s FROM i FOR j)
mysqlYesSUBSTRING(s FROM i FOR j)
oracleNoSUBSTR(s,i,j)
postgresYesSUBSTRING(s FROM i FOR j)
sqlserverYes

SUBSTRING

SUBSTRING allows you to extract part of a string.

   SUBSTRING('Hello world', 2, 3) -> 'llo'    
SELECT name,
       SUBSTR(name, 2, 5)
  FROM bbc
SELECT name,
       SUBSTRING(name, 2, 5)
  FROM bbc
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense