Introduction
Concatenation
Simple text functions
How to modify strings
15. Function substring continued
Revision

Instruction

Perfect. There is also another, extended version of substring. Take a look:

SELECT substring(name, 2, 3)
FROM item;

In the above example, substring got an additional number (3). In this way, we can specify the length of the substring we want to get. For the name 'TripCare', we'll get 'rip', because we start at letter 2 (which is 'r') and take 3 of them('r', 'I' and 'p').

Again, if you start from a number which exceeds the length of the whole string, you will get an empty string. If the second number you provide is bigger than the length until the end of the string, the database will simply return the string until its end.

Again, in Oracle this function is called substr().

Exercise

For each slogan, show its text and the characters from 3 to 8 of that text.

Stuck? Here's a hint!

If you need characters from 3 to 8, then you need to start at character 3 and take 6 characters altogether.

Console

Code editor

Result

TableConsole