Re: AVG fucntion help
| From: | Jason Wong | Date: | Sun, 30 Jun 2002 13:53:21 +0000 |
| Subject: | Re: AVG fucntion help | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20220@lists.php.net to get a copy of this message | ||
On Sunday 30 June 2002 03:15, CrossWalkCentral wrote:
> Using PHP
>
> I need some help running and AVG qery
>
> the syntax is as follows
>
> $results=sql_query("Select AVG(rate) from MYTABLENAME where id=$id",$dbi)
>
> This works but I am not sure how to get is value into a variable.
Assuming your query is correct, use:
$results=sql_query("Select AVG(rate) AS average from MYTABLENAME where
id=$id",$dbi);
This creates a column (field) called 'average' which you can extract using
whatever db query code you usually use.
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
The power to destroy a planet is insignificant when compared to the power of
the Force.
- Darth Vader
*/