简体   繁体   English

Maria DB更新和替换

[英]Maria DB Update and replace

I'm getting error message when run this: 运行此命令时出现错误消息:

UPDATE catalog_product_entity_text
SET value = REPLACE (value, 'xxxxx') 
WHERE value LIKE 'yyyyy'; 

Error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1 错误: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1 #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1

Any Ideas? 有任何想法吗?

Thanks 谢谢

I obtained the same error with the expression: 我获得了与表达式相同的错误:

UPDATE catalog_product_entity_tex
     SET value = REPLACE (value, 'yyyyy', 'xxxxx')
     WHERE value LIKE '%yyyyy%';

The solution was using alias: 解决方案是使用别名:

UPDATE catalog_product_entity_tex c
     SET c.value = REPLACE (c.value, 'yyyyy', 'xxxxx')
     WHERE c.value LIKE '%yyyyy%';

replace is wrong. replace是错误的。 Here is correct way: 这是正确的方法:

MariaDB [maison]> select replace('aaaaaa', 'a', 'b');
+-----------------------------+
| replace('aaaaaa', 'a', 'b') |
+-----------------------------+
| bbbbbb                      |
+-----------------------------+
1 row in set (0.01 sec)

Your query must be something like: 您的查询必须类似于:

UPDATE
   catalog_product_entity_text 
SET 
   value = REPLACE (value, 'xxxxx', 'zzzzz')
WHERE
   value LIKE 'yyyyy';

Replace takes three arguments, not two. 替换需要三个参数,而不是两个。 Presumably, you want: 大概,您想要:

UPDATE catalog_product_entity_tex
     SET value = REPLACE (value, 'yyyyy', 'xxxxx')
     WHERE value LIKE '%yyyyy%';

Also note the use of wildcards in the LIKE pattern. 还要注意在LIKE模式中使用通配符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM