Mybitas使用set设置自定义变量
set @csum := 0 ; select
t2.date as createTime,
DATE_FORMAT(t2.date,"%Y年%m月%d日") as createTimeStr,
IFNULL( t3.countNum, 0 ) as countNum,
(@csum := @csum + IFNULL( t3.countNum, 0 )) as sumNum
FROM
(
SELECT
@cdate := date_add( @cdate, INTERVAL - 1 DAY ) `date`
FROM
(
SELECT
@cdate := date_add( CURDATE(), INTERVAL + 1 DAY )
FROM
date_statistics
) t1
WHERE
@cdate > DATE_SUB( CURDATE(), INTERVAL 6 DAY )) t2
LEFT JOIN (
SELECT
COUNT( 1 ) AS countNum,
DATE_FORMAT( create_time, "%Y-%m-%d" ) AS createTime
FROM
ucs_subscription
WHERE
create_time >= DATE_SUB( CURDATE(), INTERVAL 7 DAY )
AND
service_type = #{serviceType}
GROUP BY
DAY ( create_time )
ORDER BY
create_time
) t3 ON t2.date = t3.createTime
ORDER BY t2.date
mybitas直接使用 set @csum := 0 ; 会报错,我们在设置数据库连接的时候设置属性allowMultiQueries=true,就可以执行了。
···
jdbc:mysql://localhost:3306/DBS?allowMultiQueries=true
以上是 Mybitas使用set设置自定义变量 的全部内容, 来源链接: utcz.com/z/518897.html