我有以下问题。
ZQuery1.SQL.Text:=
' SELECT '+
' IF(q.rank2 = 1, @rank:= 1, @rank:= @rank + 1) AS rank '+
' ,q.* FROM ( '+
' SELECT groep.id - MinGroepId(groep.id) AS rank2 '+
' ,groep.otherfields '+
' FROM groep '+
' ORDER BY rank2 ) q; ';
ZQuery.Open;
当我运行这段代码时,我在 ZQuery1 中得到一个异常 Incorrect token followed by ":"
。
我该如何解决?我需要使用 Delphi,因为我不能将此选择放入 MySQL 过程中。
Zeos 6 不支持返回结果集的 MySQL 过程。
附言
我在 ZEOS 6.6.6 中使用 Delphi 2007 和 MySQL 5.1。
虽然我很确定版本无关紧要。
我不愿意切换版本,因为我对项目的了解太深了。
最佳答案
这个不行,只能参数化值。 你能做的最好的是 SQL.Text := StringReplace() 但你失去了准备查询的速度。
关于mysql - 使用@variables := in delphi query does not work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5626480/