更新时间:2022-12-03 23:25:09
您可以简单地将表联接到进行一些计算的子查询中,
You can simply join the table in a subquery that do some calculations,
UPDATE records a
INNER JOIN
(
SELECT blah,
COUNT(*) totalCount,
SUM(amount) totalSum
FROM leads_table
GROUP BY blah
) b ON b.blah = a.blah
SET a.leads = b.totalCount
a.earnings = b.totalSum