只是无法围绕这一个正确的语法包裹我的头。下面是我的查询,对我的子查询进行简单的英语解释,并在我认为我希望它执行的地方。MySQL INSERT/SELECT子查询语法
mysql_query("INSERT INTO donations(
tid,
email,
amount,
ogrequest,
total
)
VALUES (
'".esc($p->ipn_data['txn_id'])."',
'".esc($p->ipn_data['pay_email'])."',
".(float)$amount.",
'".esc(http_build_query($_POST))."',
Here I want to select the row with the max date, get the value of the "total" column in that row, and add $amount to that value to form the new "total" for my newly inserted row.
)");
任何人都可以帮忙吗?
你是对的。我这样做的唯一原因是因为我需要经常访问它,并且想知道在数百行中不断计算SUM的开销。我想,不必遍历所有这些行,我可以从最后一行获得单个值,这对数据库来说应该不那么紧张。你会推荐什么技术来缓存它? – Jon 2011-02-02 17:57:25