1

我只是不能让它在一个过程中工作(作为一个简单的查询,它工作正常):

SET @c:=0;
SELECT
    (@c := @c + 1) AS Cumulative,
FROM
    NumberTable,
    Table
...

我认为它与“计数器”变量有关。对于我尝试的程序:

DECLARE c int(4) DEFAULT 0;
BEGIN
    SELECT
        (c = c + 1) AS Cumulative,
    FROM
        NumberTable,
        Table
    ...
END

但这不起作用(给出NULL)。有什么建议么?

PS:我认为问题可以分解为:How to SET a variable within SELECT while using a PROCEDURE(因为 := 在那里不起作用)

4

0 回答 0