语法错误 #1064
Syntax error #1064
这是我的查询:
update `zen_meta_tags_products_description`
set `metatags_keywords`= 'ice machine, ice maker, ice flaker, Brema,'
WHERE `products_id` = ('1231'; '1232'; '1233'; '1234'; '1235'; '1236'; '1237'; '1238'; '1239'; '1240';)
错误
MySQL 说:文档
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 '1232, 1233' at line 1
您不能使用 =
来比较多个值。您需要使用 IN()
。 IN()
中值的分隔符是逗号,而不是分号。最后一个也不是必需的,会导致错误。 ID 周围的引号也不是必需的,除非您确实将它们存储为字符串。
update zen_meta_tags_products_description
set metatags_keywords= 'ice machine, ice maker, ice flaker, Brema,'
WHERE products_id IN(1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240)
从列表中删除分号
而不是 = 使用 IN 来获取写入结果:
UPDATE `zen_meta_tags_products_description`
set `metatags_keywords`= 'ice machine, ice maker, ice flaker, Brema,'
WHERE `products_id` IN ('1231', '1232', '1233','1234', '1235', '1236', '1237', '1238', '1239', '1240') ;
这是我的查询:
update `zen_meta_tags_products_description`
set `metatags_keywords`= 'ice machine, ice maker, ice flaker, Brema,'
WHERE `products_id` = ('1231'; '1232'; '1233'; '1234'; '1235'; '1236'; '1237'; '1238'; '1239'; '1240';)
错误
MySQL 说:文档
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 '1232, 1233' at line 1
您不能使用 =
来比较多个值。您需要使用 IN()
。 IN()
中值的分隔符是逗号,而不是分号。最后一个也不是必需的,会导致错误。 ID 周围的引号也不是必需的,除非您确实将它们存储为字符串。
update zen_meta_tags_products_description
set metatags_keywords= 'ice machine, ice maker, ice flaker, Brema,'
WHERE products_id IN(1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240)
从列表中删除分号
而不是 = 使用 IN 来获取写入结果:
UPDATE `zen_meta_tags_products_description`
set `metatags_keywords`= 'ice machine, ice maker, ice flaker, Brema,'
WHERE `products_id` IN ('1231', '1232', '1233','1234', '1235', '1236', '1237', '1238', '1239', '1240') ;