[nycphp-talk] MySQL count( * ) syntax question
DeWitt, Michael
mjdewitt at alexcommgrp.com
Mon Feb 9 19:24:56 EST 2004
Oops I needed to correct my language about the first select:
> Chris,
>
> Since sub-selects I think are not really available, perhaps you could do
> this in two steps? select your records into a temp table and then report
> from there. Inner joins will definitely drop rows when one of the tables
> returns no rows.
>
> get everyone who has been absent one or more times
>
> select id, first, last,count(*) absences
> into temp from login
> inner join attendance on login.id = attendance.student and attendance=2
> group by id, first, last,attended
>
>
> get everyone who has never been absent
>
> select id, first, last, 0 absences
> into temp from login
> left outer join attendance on login.id = attendance.student and attendance
> not in (1,2,3)
>
>
> select id, first, last, absences from temp order by absences
>
> drop table temp
>
> Hope this helps
>
> Mike
>
>
>
>
>
>
> > -----Original Message-----
> > From: Christopher R. Merlo [SMTP:cmerlo at ncc.edu]
> > Sent: Monday, February 09, 2004 6:55 PM
> > To: NYPHP Talk
> > Subject: Re: [nycphp-talk] MySQL count( * ) syntax question
> >
> > _______________________________________________
> > talk mailing list
> > talk at lists.nyphp.org
> > http://lists.nyphp.org/mailman/listinfo/talk << Message: Untitled
> > Attachment >>
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk
More information about the talk
mailing list