In this post I would like to write about MySQL trim()
function.MySQL trim() function removes the specified characters from beginning and ending of the string and returns a string after removing all prefixes or suffixes.
NOTE :trim() function only trim excess space or specified characters on the left and right side of the text, not in between.
The syntax for the tirm() function in MySQL is:
TRIM( [ LEADING | TRAILING | BOTH ] [ trim_character FROM ] string )
Arguments
‘FROM’ IS A KEYWORD
LEADING
Optional. Indicates that only leading prefixes are to be removed. .
TRAILING
Optional. Indicates that only trailing prefixes are to be removed. .
BOTH
Optional. Removes the trim_character from the front and end of string.
trim_character
Optional. The character that will be removed from string. If this parameter is omitted, it will remove space characters from string.
string
The string to trim.
you can use trim() function in select as shown below
SELECT TRIM(title) AS title FROM your_table
if you want to remove leading trailing quote form the MySQL row and update it you can write as shown below
UPDATE `your_table` SET `title` = TRIM(BOTH '"' FROM `title`)
To remove other type of characters just replace quote with the targeted character.