views:

32

answers:

1

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 not 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?

+2  A: 

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>', '');
tomfanning
Tried this, didn't seem to remove the string from the field.
Graham
I take that back, just had to reload the table. Thanks!
Graham