0

我有一个查询,它有几个相同的求和函数。运行单独的总和查询然后将其绑定到我的原始查询作为加速它的值会更有效吗?

我当前的查询

$dbquery = $dbh->prepare("
SELECT amount - (Select SUM(amountused) from tblamountused) as amountleft
FROM tblamount
WHERE amount - (Select SUM(amountused) from tblamountused) > 0
");
4

1 回答 1

3

也许是这样的:

SELECT amount - (Select SUM(amountused) from tblamountused) as amountleft
FROM tblamount
HAVING amountleft > 0
于 2013-11-12T15:08:11.133 回答