开发者

Deleting partial data from a field in MySQL

I am trying to remove a specific set of data from a MySQL database field, however I am not sure what the best statement would be for this. For example, if I have a data in a field such as...

The use of a secondary password will allow you to gain access to your account from a non-authenticated computer. A non-authenticated computer is any computer that is no开发者_开发知识库t your primary computer, an elected authenticated computer or a computer that automatically deletes cookies. <p>This is a test</p>

...and I want to remove <p>This is a test</p> from the field, what statement would be best?


I personally would recommend the REPLACE string function: http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_replace

UPDATE table SET fieldname = REPLACE(fieldname, '<p>This is a test</p>', '');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜