我需要从表格菜单中的 url 字段中查询 remove /
原表
menuname url
home /home/
about /home/about/
要求
menuname url
home home
about home/about
这是从字段中删除尾部斜杠的方法:
UPDATE `table_name` SET `field_name`=TRIM(TRAILING '/' FROM `field_name`)
SELECT TRIM( BOTH '/' FROM '/bar/' )
编辑
SELECT TRIM(BOTH '/' FROM link ) FROM menu
见http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_trim
例子:
SELECT TRIM(BOTH '/' FROM home, about) FROM 'table_name';