Re: [PHP4BETA] re:Totalling a variable in a while loop
| From: | Joseph H Blythe | Date: | Mon, 21 Feb 2000 00:51:23 +0000 |
| Subject: | Re: [PHP4BETA] re:Totalling a variable in a while loop | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-10543@lists.php.net to get a copy of this message | ||
David Robley wrote:
>
> The SUM function in SQL should serve you well here, rather than doing
> repetitive additions in PHP. Hm, something like
>
> SELECT SUM(whatever) AS grand_total, field1, field2 FROM table WHERE
> whatever
>
> You need to give an alias to the SUM so you can reference it later.
>
Hey thanks,
I have tried this out but the manual (MYSQL) a little sparse on this
clause, what ive got upto is I have inserted all the values I want totaled
into a column and now all I want to do is total all values in that column
where whatever equals whatever, so if the field I wanted to total was
called ItemTotal and I want every value added up where UserId equals
whatever how would the syntax go?
How do I set an alias to the SUM?
I have also asked the mysql list as well but no response as of yet.
I am as thick as a brick sometimes :-)
Joseph Blythe
emailto:joe.blythe@binarylogic.com.au