这种类型的东西以前被问过几次,但不是我想要的。我需要SET
两行等于子查询的不同部分。
我目前正在使用:
UPDATE records
SET leads=(SELECT COUNT(*) FROM leads_table WHERE leads_table.blah=records.blah),
earnings=(SELECT SUM(amount) FROM leads_table WHERE leads_table.blah=records.blah)
WHERE 语句显然被简化了......但基本上它是相同的子查询,但我认为我不应该运行它两次?
我想做类似...
UPDATE records
SET (leads,earnings)=(SELECT COUNT(*),SUM(amount) FROM leads_table WHERE leads_table.blah=records.blah)