当我在Navicat的VIEWS表上运行EXPLAIN时,遇到了MySQL错误1064,但在这段简短的代码中却找不到错误的确切位置:
SET @runningbal = 0;
SELECT
cashinflow_v.TxnDate,
cashinflow_v.TxnType,
cashinflow_v.Amount,
@runningbal := @runningbal + cashinflow_v.Amount as Balance
FROM
cashinflow_v
ORDER BY cashinflow_v.TxnDate
错误提示:
[SQL] EXPLAIN SET @runningbal = 0;
SELECT
cashinflow_v.TxnDate,
cashinflow_v.TxnType,
cashinflow_v.Amount,
@runningbal := @runningbal + cashinflow_v.Amount as Balance
FROM
cashinflow_v
ORDER BY cashinflow_v.TxnDate
[Err] 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 'SET
@runningbal = 0;
SELECT
cashinflow_v.TxnDate,
cashinflow_v.TxnType,
cash' at line 1
如果有人可以帮助我,我将不胜感激。谢谢!
最佳答案
更改:
从:
EXPLAIN SET @runningbal = 0;
至
SET @runningbal = 0;