MySQL [Error] 1064



当我在 Navicat 中运行 EXPLAIN on VIEWS 表时,我收到了这个 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;

EXPLAIN 语句需要表名或以下类型之一的查询:

  • 选择
  • 删除
  • 插入
  • 取代
  • 更新

它只是不是为了提供任意SQL命令的信息而设计的(怎么可能呢?

如果是 SQL 客户端尝试解释查询,则可能需要指示它将代码块作为脚本而不是单个语句处理。

相关内容

  • 没有找到相关文章