TRIM() Function in MySQL Last Updated : 23 Sep, 2020 Comments Improve Suggest changes Like Article Like Report 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 | LEADING | TRAILING : LEADING, TRAILING, or BOTH option to explicitly instruct the TRIM() function to remove leading, trailing, or both leading and trailing unwanted characters from a string .By default, the TRIM() function uses the BOTH option. removed_str : It is a string which we want to remove. If not given, spaces will be removed. str : It identifies the string from which we want to remove removed_str. Returns : It returns a string that has unwanted characters removed. Example-1 : TRIM() function to remove only leading spaces. SELECT TRIM(LEADING FROM " www.geeksforgeeks.org ") AS TrimmedString; Output : TrimmedString www.geeksforgeeks.org Example-2 : TRIM() function to remove only trailing spaces. SELECT TRIM(TRAILING FROM " www.geeksforgeeks.org ") AS TrimmedString; Output : TrimmedString www.geeksforgeeks.org Example-3 : TRIM() function to remove both leading and trailing spaces. SELECT TRIM(" www.geeksforgeeks.org ") AS TrimmedString; Output : TrimmedString www.geeksforgeeks.org Example-4 : TRIM() function with the table data Table : Student_Details : Student_Id Student_Name 101 Virat 103 Rohit 105 Sikhar SELECT TRIM(TRAILING FROM Student_Name) FROM Student_Details AS Trimmed_String; Output : TrimmedString Virat Rohit Sikhar Comment More infoAdvertise with us Next Article TRIM() Function in MySQL J jana_sayantan Follow Improve Article Tags : SQL DBMS-SQL mysql Similar Reads 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 TIME() Function in MySQL The TIME() function in MySQL is used to extract the time portion from a date or datetime expression, returning the time in the format 'HH:MM'. This function is particularly useful when working with time components in databases, such as scheduling or logging systems. In this article, We will learn ab 4 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 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 TAN() Function in MySQL TAN() function : This function in MySQL is used to return the tangent of a specified number. In any right triangle, the tangent of an angle is the length of the opposite side divided by the length of the adjacent side. Similarly, this can also be defined as tangent of x is the sine of x divided by t 1 min read Like