On Mon, Mar 17, 2003 at 09:52:44PM -0800, Daren Cotter wrote: > Jeff, > > That query simply gives me each mailing ID, along with > the # of members associated with that mailing ID. > > What I NEED is to return the # of mailings sent to a > member, and the number of members associated with that > number. > > I.e., if I do: > > SELECT count(*) FROM member_mailings WHERE member_id = > 1 > > That returns the number of mailings for member 1, say > it's 25. That would be one tally in the "25" field for > # of mailings sent. > > It's tough to explain, so I'm thinking I won't be able > to accomplish it in one query?
Hello Daren, Assuming that your table looks something like this: +-----+-----------+---------+-----+ | ... | member_id | mail_id | ... | +-----+-----------+---------+-----+ | ... | 1 | 1 | ... | | ... | 2 | 1 | ... | | ... | 3 | 1 | ... | | ... | 1 | 2 | ... | | ... | 2 | 2 | ... | | ... | 3 | 3 | ... | +-----+-----------+---------+-----+ Then this query should return the information that you desire: SELECT COUNT(member_id), COUNT(mail_id) FROM member_mailings GROUP BY mail_id; Cheers! -- Zak Greant MySQL AB Community Advocate --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php