How can I take the sum of more than one row in my database?
Currently I have this:
$result = mysql_query('SELECT SUM(alertpay_cashout,paypal_cashout,okpay_cashout) AS value_sum FROM users');
$row = mysql_fetch_assoc($result); $sum = $row['value_sum'];
As you can see, I wish to get the sum from alertpay_cashout, paypal_cashout and okpay_cashout from all my users.
The above code does not work.
Add them with +
SELECT SUM(alertpay_cashout + paypal_cashout + okpay_cashout) AS value_sum
FROM users
SELECT (SUM(alertpay_cashout) + SUM(paypal_cashout) + SUM(okpay_cashout)) `SUM`
FROM users
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.