Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在mysql中使用@variable作为vb.net中的命令_Mysql_Vb.net - Fatal编程技术网

在mysql中使用@variable作为vb.net中的命令

在mysql中使用@variable作为vb.net中的命令,mysql,vb.net,Mysql,Vb.net,我在VB.NET 2008下使用过这种类型的查询,但每次运行它时,它总是给我一个致命错误,它告诉我要声明我使用的@variable。 下面是示例代码: select js.year, js.week, js.rem_balance, case when js.rem_balance = 0 then @prev_rem_balance else js.rem_balance end as rem_balan

我在VB.NET 2008下使用过这种类型的查询,但每次运行它时,它总是给我一个致命错误,它告诉我要声明我使用的@variable。 下面是示例代码:

select js.year, js.week, js.rem_balance,
       case when js.rem_balance = 0 
                then @prev_rem_balance 
            else js.rem_balance 
       end as rem_balance_zero_or_prev,
       @prev_rem_balance := js.rem_balance
from test_jos_stock js
       inner join (SELECT @prev_rem_balance := 0) as t
order by year,week;

您需要在select语句之前声明参数:

DECLARE @prev_rem_balance INT; --or whatever datatype it is
然后将其设置为特定值:

SET @prev_rem_balance = 1234;

您是否已尝试声明所使用的@变量?