NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL count( * ) syntax question

DeWitt, Michael mjdewitt at alexcommgrp.com
Mon Feb 9 19:22:15 EST 2004


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 more than one time

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 >> 



More information about the talk mailing list