Date: 08/04/00
- Next message: David Robley: "Re: [PHP] crypt"
- Previous message: Arnold Gamboa: "[PHP] crypt"
- In reply to: David Robley: "Re: [PHP] Generating results of a survey"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Aug 04, 2000 at 11:49:56AM +0930, David Robley wrote:
> On 3 Aug, Mike Tuller wrote:
> > Hello all,
> > Can anyone point me to an example of how to display the results of a survey
> > where the data is stored in MySql with everything calculated. I can't seem
> > to find anything in any of my books or on the web.
> >
> > Example output would be something like:
> >
> > Did you enjoy the class?
> > yes 50 no 10
> >
> >
> > Thanks,
> > Mike
> >
> >
> Very simply, use COUNT.
>
> A query like SELECT COUNT(*) AS yay FROM table WHERE vote='YES'
>
> will return one row with one field yay containing the number of 'yes'
> votes.
SELECT vote, count(*) AS cnt FROM table GROUP BY vote;
will return two rows, of the form:
vote | cnt
-----------
yes | 50
no | 10
-- Adam Haberlach | "A farm tractor is not a motorcycle." adam <email protected> | --California DMV 1999 Motorcycle Driver Handbook http://www.newsnipple.com/ |-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: David Robley: "Re: [PHP] crypt"
- Previous message: Arnold Gamboa: "[PHP] crypt"
- In reply to: David Robley: "Re: [PHP] Generating results of a survey"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

