Difference between revisions of "SUBSTRING(ansi)"
From SQLZOO
| Line 4: | Line 4: | ||
<tr><td align='center'>'''Engine'''</td><td align='center'>'''OK'''</td><td align='center'>'''Alternative'''</td></tr> | <tr><td align='center'>'''Engine'''</td><td align='center'>'''OK'''</td><td align='center'>'''Alternative'''</td></tr> | ||
<tr><td align='left'>ingres</td><td>Yes</td><td>[[SUBSTRING |SUBSTRING(s,i,j)]]</td></tr> | <tr><td align='left'>ingres</td><td>Yes</td><td>[[SUBSTRING |SUBSTRING(s,i,j)]]</td></tr> | ||
| + | <tr><td align='left'>mysql</td><td>Yes</td><td></td></tr> | ||
<tr><td align='left'>oracle</td><td>No</td><td>[[SUBSTR |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 |SUBSTRING(s,i,j)]]</td></tr> | <tr><td align='left'>postgres</td><td>Yes</td><td>[[SUBSTRING |SUBSTRING(s,i,j)]]</td></tr> | ||
Revision as of 10:59, 28 October 2012
| SUBSTRING(s FROM i FOR j) | ||
|---|---|---|
| Engine | OK | Alternative |
| ingres | Yes | SUBSTRING(s,i,j) |
| mysql | Yes | |
| oracle | No | SUBSTR(s,i,j) |
| postgres | Yes | SUBSTRING(s,i,j) |
| sqlserver | No | SUBSTRING(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 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
SELECT name, SUBSTRING(name FROM 2 FOR 5) FROM bbc
See also
| Language: | English • Deutsch |
|---|