[英]remove a character from beginning of a field value in MySql
I have about 2000 records in a MySql table. 我在MySql表中有大约2000条记录。 a specific field in some of them starts with colon character (:) that is not needed.
其中一些特定字段以不需要的冒号(:)开头。 I have to remove this character from the beginning of it.
我必须从其开头删除此字符。
How can I do that ? 我怎样才能做到这一点 ? Should I use regular expression ?
我应该使用正则表达式吗?
you can remove the first character using SUBSTR
function. 您可以使用
SUBSTR
函数删除第一个字符。 Like 喜欢
UPDATE tableName SET field = SUBSTR(field, 2) WHERE field LIKE ':%';
or you can use regex
also, to match beginning character ( ^
) of the word. 或者也可以使用
regex
来匹配单词的开头字符( ^
)。 Here is the link for how to use regex
. 这是如何使用
regex
的链接 。
UPDATE tableName
SET columnName = REPLACE(columnName, ':', '')
WHERE columnName LIKE ':%'
you could do something like: 您可以执行以下操作:
UPDATE TABLE
SET FIELD = SUBST(FIELD,1)
WHERE LEFT(FIELD,1) = ':'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.