MySQL语法错误 - 显而易见?

时间:2011-11-23 00:35:26

标签: mysql syntax-error mysql-error-1064

有人能发现这件事的语法错误吗?

UPDATE `inventory` 
LEFT JOIN `manufacturers` ON (
  `man_id` = `manufacturers`.`id`
)
LEFT JOIN `meta_tags` ON (
  `meta_tags`.`page_url` = REPLACE(REPLACE(`manufacturers`.`title`, " ", "_"), "\", "_")
)
SET `inventory`.`tag_ids` = CONCAT_WS("," `tag_ids`, `tag_id`)
WHERE FIND_IN_SET(`tag_id`, `tag_ids`) = 0

错误讯息:

 #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 
 '_" ) ) SET `inventory`.`tag_ids` = CONCAT_WS("," `tag_'

2 个答案:

答案 0 :(得分:3)

您可能需要转义外部\功能中的REPLACE()。尝试使用

REPLACE(REPLACE(`manufacturers`.`title`, " ", "_"), "\\", "_")

取代你所拥有的。 Here's the MySQL reference解释字符转义序列。

答案 1 :(得分:3)

另外

CONCAT_WS("," `tag_ids`, `tag_id`)

应该是

CONCAT_WS(",", `tag_ids`, `tag_id`)

(缺少逗号)