直接执行SQL没有问题
SET @i :=- 1;
SELECT
date_format( DATE_SUB( '2019-08-13', INTERVAL ( @i := @i + 1 ) DAY ), '%Y-%m-%d' ) AS `time`
FROM
changegroup
WHERE
@i <= 10
但在java代码里报错,提示语法错误,希望各位码友指教,如何解决?
直接执行SQL没有问题
SET @i :=- 1;
SELECT
date_format( DATE_SUB( '2019-08-13', INTERVAL ( @i := @i + 1 ) DAY ), '%Y-%m-%d' ) AS `time`
FROM
changegroup
WHERE
@i <= 10
但在java代码里报错,提示语法错误,希望各位码友指教,如何解决?
改成这样写:
SELECT
date_format( DATE_SUB( '2019-08-13', INTERVAL ( @i := @i + 1 ) DAY ), '%Y-%m-%d' ) AS time
FROM
changegroup ,
(SELECT @i :=- 1) i
WHERE
@i <= 10