Question

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?

Was it helpful?

Solution

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%';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top