Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个查询,它有几个相同的求和函数。运行单独的总和查询然后将其绑定到我的原始查询作为加速它的值会更有效吗?
我当前的查询
$dbquery = $dbh->prepare(" SELECT amount - (Select SUM(amountused) from tblamountused) as amountleft FROM tblamount WHERE amount - (Select SUM(amountused) from tblamountused) > 0 ");
也许是这样的:
SELECT amount - (Select SUM(amountused) from tblamountused) as amountleft FROM tblamount HAVING amountleft > 0