-1

I need to write a query that will delete this string float:right; from inside a column called description.

This database is in BlueHost and no mater what query I try, Bluehost is giving me this error:

#1064 - You have an error in your SQL syntax; 
check the manual that corresponds to your 
MySQL server version for the right syntax to use near 'field like
 '% float:right%' at line 1

This is the last query I tried:

DELETE FROM tablename WHERE `description` field like '% float:right%'

What am I doing wrong?

4

1 回答 1

1

You don't want to delete. That deletes rows. You want to update:

update tablename
    set description = replace(description, 'float:right;', '')
    where description like '% float:right;%';

If you want to delete all rows that match that pattern, then your original query is pretty close:

delete from tablename
    where description like '% float:right%';

To see what rows would be affected by either query, use:

select *
from tablename
where description like '% float:right%';
于 2013-06-01T22:32:38.203 回答