SQL Substring is an inbuilt function that is used to extract the part of a string from an original string given as an input to the function. Part of the string is known as a substring. The SUBSTRING functions allow you to extract a substring from a string.

SQL Substring Function

SQL SUBSTRING() method allows us to obtain the substring from the main string. If there is some use case like you want to check the part of the output string then you can use the substring() function.

See the syntax of the Substring function.

SELECT SUBSTRING (input_string, start_position, length);

See the following parameters.

  1. input_string: The source string from which substring will be extracted. It can be a character, binary, text, or image expression.
  2. start_position: It is an integer that specifies the location where the returned substring starts. The first character in an input_string is 1, not zero as that of in C or C++.
  3. **Length: **It is a positive integer that specifies the number of characters to be extracted. The function will raise an error if the length is negative.

If the start + length > the length of input_string, a substring will begin at the start and will include the remaining characters of the input_string.

#sql #sql substring

SQL Substring Function Example | Substring In SQL
1.10 GEEK