如何删除float:right;从MySQL表列?

时间:2013-06-01 22:13:10

标签: mysql bluehost

我需要编写一个删除此字符串的查询:float:right;来自名为description的列内。

这个数据库在BlueHost中并且没有我尝试的查询,Bluehost给了我这个错误:

#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

这是我尝试的最后一个查询:

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

我做错了什么?

1 个答案:

答案 0 :(得分:1)

您不想delete。删除行。您想要更新:

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

如果要删除与该模式匹配的所有行,则原始查询非常接近:

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

要查看哪个行会受到任一查询的影响,请使用:

select *
from tablename
where description like '% float:right%';