SUBSTRING function
SUBSTRING function
The SUBSTRING (expression , start , length) function allows us to extract from an expression its part of a pecified length, starting from a specified initial position (start). Expression may be a character or a binary string, and also can have a text or image type. For example, if we need to get 3 characters in a ship name, starting from the 2nd character, then it’s not quite easy to do it without the SUBSTRING function. And so we write:
SELECT name, SUBSTRING(name, 2, 3)
FROM Ships
🚫
[[ error ]]
[[ column ]] |
---|
[[ value ]] |
In case we need to extract all the characters, starting from the certain, we also can use this function. For example,
SELECT name, SUBSTRING(name, 2, LEN(name))
FROM Ships
🚫
[[ error ]]
[[ column ]] |
---|
[[ value ]] |
Suggested exercises: 136