Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Simple text functions
How to modify strings
14. Function substring


Very well done! Okay. The functions we've learned so far operated on all the 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 larger than the whole string length, then 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. Name the second column name_substring.

Stuck? Here's a hint!

Use substring(name, 3).