开发者

How to delete part of a MySQL database record?

开发者 https://www.devze.com 2022-12-24 13:28 出处:网络
I want to delete part of a record. For example, a column called \"message\" contains the following string:

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

精彩评论

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