mysql数据库,使用union all 关联临时表中,临时表数据共享
(
SELECT@orderTimes := order_time,
@afteramount := after_amount afteramount
FROM
sid_acct_balancelog t
WHERE
1 = 1
AND t.cust_id = '1853'
)
UNION ALL
(
SELECT
tt.order_time,
SUM(tt.amount) afteramount
FROM
sid_acct_balancelog tt
WHERE
1 = 1
AND tt.order_time >= (SELECT @orderTimes)
)