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 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 SQL Server SUBSTRING() Function The SQL Server SUBSTRING function extracts a substring from a string, starting at a specified position and with an optional length. The SUBSTRING function also works in Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse. SyntaxThe SQL SUBSTRING function syntax is: SUBSTRING(in 3 min read STRCMP() Function in MySQL STRCMP() function in MySQL is used to compare two strings. If both of the strings are same then it returns 0, if the first argument is smaller than the second according to the defined order it returns -1 and it returns 1 when the second one is smaller the first one. Syntax : STRCMP(Str1, Str2) Param 3 min read SQL | String functions SQL String Functions are powerful tools that allow us to manipulate, format, and extract specific parts of text data in our database. These functions are essential for tasks like cleaning up data, comparing strings, and combining text fields. Whether we're working with names, addresses, or any form 7 min read SOUNDEX() Function in MySQL SOUNDEX() function in MySQL is used to return a phonetic representation of a string. The phonetic represents the way the string will sound. The SOUNDEX function helps to compare words that are spelled differently, but sound alike in English. Syntax : SOUNDEX(str) Parameter : SOUNDEX() function accep 3 min read PLSQL | SUBSTR Function The PLSQL SUBSTR function is used for extracting a substring from a string. The SUBSTR function accepts three parameters which are input_string, start_position, length. SUBSTR calculates lengths using characters as defined by the input character set. SUBSTRB uses bytes instead of characters. Note: I 2 min read Like