MySQL Forums
Forum List  »  PHP

Re: num_rows not working when used SUM()
Posted by: Onkar Shinde
Date: February 28, 2015 02:32AM

Thank you for the reply Peter.

I am sorry, do i SUM(prices.priceid) in the query itself or after i get the results and then i Sum?

$query = "SELECT items.itemid, prices.priceid  FROM items 
JOIN prices ON items.itemid = prices.itemid AND SUM(prices.priceid) as PR
WHERE items.clientid = '$clientid'";

Please help. I believe SUM for the results is not recommended. You should SUM in the query itself. Is it true? Especially for a DB with lots of rows.

Options: ReplyQuote


Subject
Written By
Posted
Re: num_rows not working when used SUM()
February 28, 2015 02:32AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.