SQLzoo.net

Substring: Extracting part of a string.

Oracle
We from position 1 (the beginning) we take two characters. 4.
'Afghanistan' -> 'Af'
'China'       -> 'Ch'
'Sri Lanka'   -> 'Sr'
The SQL standard insists on a horrible syntax:
SUBSTRING(name FROM 1 FOR 2)


Specific to Oracle
See also SUBSTR
SELECT name, SUBSTR(name,1,2)
 FROM cia
 WHERE region = 'Asia'

Related links:

  • FUNCTIONS