mysql数据库,使用union all 关联临时表中,临时表数据共享

来源:互联网 发布:淘宝店铺手抄报 编辑:程序博客网 时间:2024/06/05 04:31

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)
)
阅读全文
1 0
原创粉丝点击