NYCPHP Meetup

NYPHP.org

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

Christopher R. Merlo cmerlo at ncc.edu
Mon Feb 9 18:54:53 EST 2004


On 2004-02-09 18:48 -0500, Tim Gales <tgales at tgaconnect.com> wrote:

> You might try adding a 'sentinel' record.

Well, the table where the zero counts should occur is a table of
students' attendance records.  Each row has a date, student ID, and in
column "attended", a value of 1, 2, or 3.  1 = present, 2 = absent, 3
= excused.

The query basically looks like this:
select id, first, last, etc., count( attended )
from login, attendance
where id = student /* where login.id = attendance.student */
and attended = 2
group by...

Basically, I want to select every student, and the amount of times
he/she was absent (including never).  But I only get the students who
were absent at least once.  I can't think of another way to get that,
other than what feels like it would be a severe kludge.

-- 
  cmerlo at ncc.edu             http://turing.matcmp.ncc.edu/~cmerlo

In theory, there is no difference between theory and practice.  In
practice, there is.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20040209/29fcdefa/attachment.sig>


More information about the talk mailing list