MySQL trim function

Rate this post

MySQL TRIM() function returns a string after removing all prefixes or suffixes from the given string.


TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM ] str)


Name Description
BOTH Indicates that prefixes from both left and right are to be removed.
LEADING Indicates that only leading prefixes are to be removed.
TRAILING Indicates that only trailing prefixes are to be removed.
remstr The string to be removed.
FROM Keyword
str The actual string from where remstr is to be removed.


mysql> SELECT TRIM(' trim '); 
| trim           | 
1 row in set (0.00 sec)

Related Posts

  • 69
    MySQL has a RAND function that can be invoked to produce random numbers between 0 and 1: mysql> SELECT RAND( ), RAND( ), RAND( ); +------------------+-----------------+------------------+ | 0.45464584925645 | 0.1824410643265 | 0.54826780459682 | +------------------+-----------------+------------------+ 1 row in set (0.00 sec) When invoked with an integer argument, RAND( ) uses that…
    Tags: mysql, set, select, function, string
  • 69
    MySQL LOCATE() returns the position of the first occurrence of a string within a string. Both of these strings are passed as arguments. An optional argument may be used to specify from which position of the string (i.e. string to be searched) searching will start. If this position is not…
    Tags: mysql, string, str, select, returns, syntax, arguments, function
  • 65
    Syntax: IF(expr,if_true_expr,if_false_expr) MySQL IF function is control flow functions that returns a value based on a condition. The IF function is sometimes referred to as IF ELSE or IF THEN ELSE function. If the expr evaluates to TRUE i.e., expr is not NULL and expr is not 0, the IF…
    Tags: function, returns, select, example, mysql
  • 54
    Description: MySQL LENGTH() returns the length of a given string. Syntax: LENGTH (str) Argument: Name      Description str            A string whose length is to be returned. Example of MySQL LENGTH() function mysql> SELECT LENGTH(NULL); Result: NULL mysql> SELECT LENGTH(''); Result: 0 mysql> SELECT LENGTH('…
    Tags: mysql, select, str, description, function, string
  • 53
    MySQL SUBSTRING() returns a specified number of characters from a particular position of a given string. Syntax: SUBSTRING(str, pos, len) or SUBSTRING(str FROM pos FOR len) Arguments Name       Description str              A string. pos             Starting position.…
    Tags: mysql, select, set, row, function, string

Satya Prakash

VOIP Expert: More than 8 years of experience in Asterisk Development and Call Center operation Management. Unique Combination of Skill Set as IT, Analytics and operation management.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: