How to remove leading and trailing slashes in mysql

I need to request removal / from url fields in table menu

original table

menuname url
home     /home/
about    /home/about/

demand

menuname   url
home       home
about      home/about
+5
source share
3 answers
SELECT TRIM( BOTH  '/'    FROM  '/bar/' )     

EDIT

SELECT TRIM(BOTH  '/' FROM link ) FROM menu
+7
source

Here's how you remove trailing slashes from a field:

UPDATE `table_name` SET `field_name`=TRIM(TRAILING '/' FROM `field_name`)
+7
source

See http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_trim

Example:

SELECT TRIM(BOTH '/' FROM home, about) FROM 'table_name'; 
+3
source

All Articles