Simple text functions
How to modify strings
14. Function substring


Very well! Okay. The functions we've learned so far did something to entire string values, but we can also manipulate certain fragments or even single letters.

We'll start off with substring(x, y). Take a look:

SELECT substring(name, 2)
FROM item;

What does the function substring do? It returns part of the string starting from the character specified as y, which must be an integer value.

In this case, if the name is 'TripCare' and y = 2, we'll get 'ripCare' as the result, because the database will start at the second character, which is 'r'.

If the integer y you provide is longer than the whole string, you will get an empty string '' as a result.

In Oracle, this function is called substr().


Show the full name of each item and each name starting from the 3rd character.

Stuck? Here's a hint!

Use substring(name, 3).


Code editor