gpt4 book ai didi

mysql - 准备 STMT 语句给出语法错误

转载 作者:行者123 更新时间:2023-11-29 09:31:18 28 4
gpt4 key购买 nike

我在此处运行准备 stmt 时遇到语法错误。我尝试手动执行 @c 中的查询并且它有效。不知道为什么 stmt 会给出这个错误。这是我正在使用的代码。

SET @i=24;
SET @Bill_month='2019-01-01';
SET @STARTDATE= date_sub( @Bill_month,interval @i MONTH);
SET @ENDDATE= date_sub( @Bill_month,interval @i - 1 MONTH);
SET @TABLENAME= CONCAT('BA_DEV.INVOICE',MONTH(@Bill_month),'_',@i);
SET @c := CONCAT('DROP temporary TABLE if exists tempdb.cohort_month;

CREATE temporary TABLE if not exists tempdb.cohort_month
select * from ba_dev.invoice_',EXTRACT(YEAR_MONTH FROM @STARTDATE),'_ongoing_STEP2;');

PREPARE stmt from @c;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

最佳答案

只能执行一条语句,先执行 drop,再执行 create。

关于mysql - 准备 STMT 语句给出语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58640411/

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