0

I have a MySQL database called arch, with a table called resources, which has a text field called title. I'm working on normalizing the title field; sometimes it ends with a period, sometimes it doesn't. I'd like to remove all trailing periods. I'm afraid of using the replace function because the title field does contain valid periods within the data.

I've tried using

SELECT TRIM(TRAILING '.' FROM 'title')

but am not having luck. I think this must be simple. Shouldn't this be possible within MySQL?

EDIT:

I read elsewhere that TRIM() does not work on SELECT function. I rewrote the statement into

UPDATE resources SET title = TRIM(TRAILING '.' FROM title)

and success!

Thanks all for the help.

4

1 回答 1

2

你是怎么用的trim()?通过指定要修剪的字符,它应该可以工作;

select trim(trailing '.' from `your_column`)...

编辑,

使用 时,您没有引用列trim(),而是指向字符串。删除单引号,或用记号 (`) 替换它们。

于 2012-10-05T14:17:13.733 回答