Syntax
SELECT SUBSTRING (
This function returns a specified number of characters from a string, starting at a specified location.
Parameters
-
: The string from which to extract a substring. -
: The zero-based location from which to start extracting the substring. -
: The number of characters to extract.
Return Value
Returns the specified substring. If
Examples
Example 1: Extracting a string from a name
SELECT SUBSTRING('John Doe', 1, 4);
Returns: 'John'
Example 2: Extracting a string from a full name
SELECT SUBSTRING('John Doe', 5, 2);
Returns: 'Doe'
Example 3: Extracting from a numeric string
SELECT SUBSTRING('12345', 2, 3);
Returns: '345'