Difference between revisions of "SUBSTRING"
Jump to navigation
Jump to search
Line 18: | Line 18: | ||
<div class='ht'> | <div class='ht'> | ||
In this example you get the 2nd to 5th character from each country's name. | |||
<source lang='sql' class='def e-oracle'> | <source lang='sql' class='def e-oracle'> | ||
SELECT name, | SELECT name, |
Revision as of 11:02, 28 October 2012
SUBSTRING(s, i, 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 get the 2nd to 5th character from each country's name.
SELECT name,
SUBSTR(name, 2, 5)
FROM bbc
SELECT name,
SUBSTRING(name, 2, 5)
FROM bbc
Language: | English • Deutsch |
---|