Difference between revisions of "SUBSTRING"
From SQLZOO
(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 9: | Line 9: | ||
<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 | + | <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' | + | SUBSTRING('Hello world', 2, 3) -> 'llo' |
</pre> | </pre> | ||
Revision as of 14:18, 16 July 2012
| SUBSTRING(s FROM i FOR j) | ||
|---|---|---|
| Engine | OK | Alternative |
| ingres | Yes | SUBSTRING(s FROM i FOR j) |
| mysql | Yes | SUBSTRING(s FROM i FOR j) |
| oracle | No | SUBSTR(s,i,j) |
| postgres | Yes | SUBSTRING(s FROM i FOR j) |
| sqlserver | Yes | |
SUBSTRING
SUBSTRING allows you to extract part of a string.
SUBSTRING('Hello world', 2, 3) -> 'llo'
In this example you put the region and the name together for each country.
SELECT name, SUBSTR(name, 2, 5) FROM bbc
SELECT name, SUBSTRING(name, 2, 5) FROM bbc