Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to delete part of a string found in a particular field.

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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
366 views
Welcome To Ask or Share your Answers For Others

1 Answer

When you want to edit a field, you need an UPDATE statement:

UPDATE table SET fieldname=REPLACE(fieldname,'APS','')

REPLACE is a string function that replaces every occurence of the 2nd string in the 1st string with the 3rd one.

Please try this with a WHERE clause first, to see if it is really what you want to do.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...