SQL question

From: Andrew Darby <adarby_at_nyob>
Date: Mon, 29 Nov 2004 16:17:57 -0500
To: CODE4LIB_at_listserv.nd.edu
Hello, all.  Based on the pretty SQL I saw in some recent posts, I
thought I would fall on the mercy of the crowd, and see if anyone could
help . . .

I'm trying to display (using MySQL/PHP) a list of subject librarians and
their associated subjects, in a neat table.  This gets me close:

SELECT lname, fname, title, tel, email, supersubject FROM supersubs,
staff WHERE supersubs.staff_id = staff.staff_id GROUP BY lname

except only the first associated subject is delivered.

The following query gets me all the data I need, but with all the
librarian info duplicated:

SELECT lname, fname, title, tel, email, supersubject FROM supersubs,
staff WHERE supersubs.staff_id = staff.staff_id GROUP BY lname, supersubject

Is there a way, in the SQL, to generate my "mama bear" set: i.e., with
the subjects grouped together like so:

Smith, Joe | English, History, Italian | 425-5000 | joe_at_college.edu
Turner, Ted | Math, Politics, Zoology | 425-5111 | ted_at_college.edu

Or do I have to run another query inside the php loop?  (I seem to
remember, from a previous life, that you could do these "queries within
queries" in ColdFusion.)

Thanks, and I hope this doesn't qualify as a dumb question . . .

Andrew Darby
Received on Mon Nov 29 2004 - 16:26:34 EST