
If you omit the length parameter, the substring function returns the whole string started at start_position. If the sum of start_position and length is greater than the number of characters in the string, the substring function returns the whole string beginning at start_position. The substring () method extracts characters, between two indices (positions), from a string, and returns the substring. The default value of starting position is 0. It returns the index of the first occurrence of the substring in the string from given starting position.
length is a positive integer that determines the number of characters that you want to extract from the string beginning at start_position. String find is used to find the first occurrence of sub-string in the specified string being called upon. Though in other database systems such as MySQL the substring function can accept a negative start_position. If start_position equals zero, the substring starts at the first character of the string. length : An optional parameter that can be used to specify the requested number of characters in the substring. startingIndex : The zero-based starting character position of the requested substring.
start_position is an integer that specifies where you want to extract the substring. source: The source string that the substring will be taken from. string is a string whose data type is char, varchar, text, etc. SUBSTRING ( string ,start_position, length ) Code language: SQL (Structured Query Language) ( sql )