SUBSTRING() function in MySQL Last Updated : 22 Sep, 2020 Comments Improve Suggest changes Like Article Like Report SUBSTRING() : function in MySQL is used to derive substring from any given string .It extracts a string with a specified length, starting from a given location in an input string. The purpose of substring is to return a specific portion of the string. Syntax : SUBSTRING(string, start, length) OR SUBSTRING(string FROM start FOR length) Parameters : This method accepts three-parameter as mentioned above and described below. string - Input String from which to extract. start - The starting position. If it is a positive number, this function extracts from the beginning of the string. If it is a negative number, this function extracts from the end of the string. length - It is optional. It identifies the number of characters to extract. If it is not given The whole string is returned from the starting position. Example-1 : Deriving substring from a given string without giving length parameter. SELECT SUBSTRING("GeeksForGeeks", 3) AS Sub_String; Output : Sub_StringeksForGeeks Example-2 : Deriving substring from a given string when length parameter is given. SELECT SUBSTRING("GeeksForGeeks", 3, 8) AS Sub_String; Output : Sub_StringeksForGe Example-3 : Deriving substring from a given string when starting position is -ve, i.e: starting from end. SELECT SUBSTRING("GeeksForGeeks", -3 ) AS Sub_String; Output : Sub_Stringeks Example-4 : Extracting all substring from the text column in a Table. Table : Student_Details Student_IdStudent_Name101Virat102Rohit103Rahul104Sikhar SELECT SUBSTRING( Student_Name, 2 ) AS Sub_String FROM Student_Details ; Output : Sub_Stringiratohitahulikhar Comment More infoAdvertise with us Next Article SUBSTRING() function in MySQL J jana_sayantan Follow Improve Article Tags : SQL mysql Similar Reads SUBSTRING_INDEX() function in MySQL SUBSTRING_INDEX() function in MySQL is used to return a substring from a string before a specified number of occurrences of the delimiter. Syntax : SUBSTRING_INDEX( str, delim, count ) Parameter : This method accepts three-parameter as mentioned above and described below : str : The original string 2 min read TRIM() Function in MySQL TRIM() function in MySQL is used to clean up data. It is also used to remove the unwanted leading and trailing characters in a string. Syntax : TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str) Parameter : This method accepts three-parameter as mentioned above and described below : BOTH | LEADIN 2 min read RTRIM() Function in MySQL RTRIM() : It is the function in MySQL that is used to remove trailing spaces from a string. Syntax : RTRIM(str) Parameter : RTRIM() function accepts one parameter as mentioned above and described below. str âThe string from which we want to remove trailing spaces. Returns : It returns a string after 3 min read RIGHT() Function in MySQL RIGHT() function in MySQL is used to extract a specified number of characters from the right side of a given string. Second argument is used to decide, how many characters it should return. Syntax : RIGHT( str, len ) Parameter : This function accepts two parameter as mentioned above and described be 3 min read POSITION() function in MySQL POSITION() : This function in MySQL is used for finding the location of a substring in a string. It will return the location of the first occurrence of the substring in the string. If the substring is not present in the string then it will return 0. When searching for the location of a substring in 2 min read Like