删除MYSQL中的一部分字符串 [英] Deleting part of a string in MYSQL
本文介绍了删除MYSQL中的一部分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除在特定字段中找到的字符串的一部分.
I want to delete part of a string found in a particular field.
例如,该字段中的条目可以是"01365320 APS ".我正在删除"APS".
For example, the entry in the field could be "01365320APS". The "APS" is what I am looking at deleting.
我的问题是,我应该使用:
My question is, should I use:
SELECT SUBSTRING_INDEX('fieldname','APS', 1)
推荐答案
要编辑字段时,需要UPDATE
语句:
When you want to edit a field, you need an UPDATE
statement:
UPDATE table SET fieldname=REPLACE(fieldname,'APS','')
REPLACE
是一个字符串函数,它将第一个字符串中第二个字符串的每个出现都替换为第三个字符串.
REPLACE
is a string function that replaces every occurence of the 2nd string in the 1st string with the 3rd one.
请首先使用WHERE
子句尝试该操作,以查看它是否确实是您想要的.
Please try this with a WHERE
clause first, to see if it is really what you want to do.
这篇关于删除MYSQL中的一部分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文