gpt4 book ai didi

mysql - 在 heidisql 查询选项卡中声明 mysql 变量

转载 作者:可可西里 更新时间:2023-11-01 07:20:12 27 4
gpt4 key购买 nike

我像这样在 heidisql 选项卡中声明了一个变量

DECLARE total_count INT DEFAULT 0;
SET total_count = 10;
select total_count;

但是我得到了这个错误

/* SQL Error (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 'DECLARE total_count INT DEFAULT 0' at line 1 / / Affected rows: 0 Found rows: 0 Warnings: 0 Duration for 0 of 3 queries: 0.000 sec. */

我应该像我所做的那样声明、设置和使用变量,还是必须将所有内容包装在存储过程或函数中?

最佳答案

试试这个:

SET @total_count := 10;
select @total_count;

关于mysql - 在 heidisql 查询选项卡中声明 mysql 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26273201/

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