gpt4 book ai didi

Mysql执行简单代码时出错

转载 作者:行者123 更新时间:2023-11-30 23:05:05 25 4
gpt4 key购买 nike

我发出了一个 SQL 请求,其中包含一个已经可用的函数,如下所示:

SELECT fnStripTags('this <html>is <b>a test</b>, nothing more</html>');

当我执行这段 SQL 代码时:

INSERT INTO `ps_product_lang` (`description`) VALUES (
SELECT fnStripTags(description) FROM ps_product_lang
WHERE ps_product_lang.id_lang = id_lang AND ps_product_lang.id_product = id_product
) WHERE description IS NOT NULL

我遇到了这个错误:

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 'SELECT fnStripTags(ps_product_lang.description) FROM
ps_product_lang WHERE ps_pr' at line 1

最佳答案

insert-select 语句中没有 values 关键字:

INSERT INTO ps_product_lang (description) 
SELECT fnStripTags(description)
FROM ps_product_lang
WHERE ps_product_lang.id_lang = id_lang AND
ps_product_lang.id_product = id_product AND
description IS NOT NULL

关于Mysql执行简单代码时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22255128/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com