我有两个表,brp_consume_log
和brp_transfer_log
,我在表格中加入了查询:
SELECT *
FROM brp_consume_log a
JOIN brp_transfer_log b ON b.acct_id = a.acct_id
WHERE a.acct_id ='1657'
结果输出为:
我想以下面的格式显示结果:
有可能吗?
更新 我已经能够使用下面的查询输出我想要的结果:
SELECT
datetime,
remark,
intake,
consume
FROM
(
SELECT datetime, remark, points_intake intake, NULL consume, 1 ord
FROM brp_transfer_log
WHERE acct_id = '1657'
UNION ALL
SELECT datetime, remark, NULL, point_consume, 2
FROM brp_consume_log
WHERE acct_id = '1657'
) q
ORDER BY datetime DESC, ord
顺便说一下,如何为balance points
添加另一个字段并从上一个余额点进行必要的减法或加法?
请指教。谢谢!