MySQL mysql切字符串,第一个字符?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2226415/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mysql cut string, the first character?
提问by mysqllearner
Hi is it possible to cut string like this:
嗨,是否可以像这样切割字符串:
String in "data" columns: ,123,456
“数据”列中的字符串:,123,456
Cut the first character i.e "," (comma).
剪切第一个字符,即“,”(逗号)。
So the query is something like:
所以查询是这样的:
Update users set data = cut first string...
回答by James Cronen
UPDATE users SET data = SUBSTR(data, 2);
UPDATE users SET data = SUBSTR(data, 2);
This will iterate through all rows in users
and replace data
with itself minus the first character.
这将遍历所有行users
并替换data
为自身减去第一个字符。