此查询从 linux cli 执行的 .sql 文件中运行良好。当我从 phpmyadmin 执行它时,它会启动一个睡眠进程,并且服务器上的 http 守护进程达到 99% 的 cpu 使用率,几分钟后查询由于“内部服务器错误”而失败。有任何想法吗?
INSERT INTO Balance(id, Bal)
SELECT a.id, SUM(a.Amount)
FROM(
SELECT ct.id, SUM(ct.Charges) as Amount
FROM ChargesT ct
GROUP BY ct.id
UNION ALL
SELECT pt.id, -SUM(pt.PaymentAmt) as Amount
FROM PaymentsT pt
GROUP BY pt.id
) a
GROUP BY a.id