MYSQL替换就像没有工作

时间:2015-12-05 13:24:29

标签: mysql replace sql-like

我的查询有问题:

UPDATE 
    `MY_COLOR` 
SET 
    `Color` = REPLACE(`Color`, ' ', '') 
WHERE 
    `Color` LIKE ('L %')

相同的查询没有" WHERE Color LIKE(' L%')"工作

错误:

#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 'FROM `MY_COLOR` WHERE `Color` LIKE ( 'L %' )' at line 3

1 个答案:

答案 0 :(得分:0)

LIKE子句中存在语法错误。 使用 SELECT * FROM TABLE WHERE field1 like '%abc%'; 所以在你的情况下,它将是
UPDATE MY_COLOR SET Color = REPLACE(Color, ' ', '') WHERE Color LIKE 'L %';