开发者

How to delete part of a MySQL database record?

I want to delete part of a record. For example, a column called "message" contains the following string:

"Hi, My name is John"

I want to delete just "John" from开发者_开发技巧 the above while retaining the "Hi, My name is" part in tact.

How can this be done?


You don't delete anything; the row is updated.

UPDATE table_name SET
message = "Hi, My name is"
WHERE message = "Hi, My name is John"


This would work:

UPDATE SomeTable SET message = REPLACE(message, "John", "") WHERE id = 123;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜