Actually, I did get it figured out...it was a small mistake

SELECT DISTINCT(a.ref1) AS member_id, count(*) AS count, b.password,
concat(UCASE(SUBSTRING(b.first_name,1,1))
, LCASE(SUBSTRING(b.first_name,2,LENGTH(b.first_name)))) AS name, b.email,
b.html_mail, b.ref1, DATE_FORMAT(b.signup_
date, '%b %e, %Y') AS signup_date FROM members AS a, members AS b WHERE
a.active_member = 'Y' AND a.ref1 = b.member_i
d GROUP BY a.ref1 ORDER BY count DESC LIMIT 20;



Daren Cotter
CEO, InboxDollars.com
http://www.inboxdollars.com
(507) 382-0435

-----Original Message-----
From: Paul DuBois [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 22, 2001 12:58 PM
To: Daren Cotter; [EMAIL PROTECTED]
Subject: Re: Referer Count


At 2:31 PM -0800 3/22/01, Daren Cotter wrote:
>I have a table, which keeps track of member information (including which
>member referred the member). To get a count of the # of referrals for
member
>25, my query is:
>
>SELECT COUNT(*) FROM members WHERE ref1 = 25;
>
>To get a list of the top referers and the # of referrals they have, my
query
>is:
>
>SELECT DISTINCT(ref1) AS member_id, COUNT(*) AS count FROM members GROUP BY
>ref1 ORDER BY count DESC LIMIT 100
>
>However, what I need, is a list of the top referers, along with their
member
>information...name, email, password, etc. I tried using the following
query,
>as I read about it in the MySQL manual, but it doesn't work:

You're asking for a summary as well as a listing.  You'll need two queries.
One to get the member_id for the top 25 referers, another to pull the
information for those members.  You can use ...WHERE member_id IN (list)
on the second query, where "list" is a comma separated list of the member_id
values.  Probably best to put this stuff in a Perl script or something so
that you can manipulate the list and construct the queries easily.

>
>SELECT DISTINCT(a.ref1) AS member_id, count(*) AS count, b.password,
>concat(UCASE(SUBSTRING(b.first_name,1,1)),
>LCASE(SUBSTRING(b.first_name,2,LENGTH(b.first_name)))) AS name, b.email,
>b.html_mail, b.ref1, DATE_FORMAT(b.signup_date, '%b %e, %Y') AS signup_date
>FROM members AS a, members AS b WHERE a.active_member = 'Y' AND a.ref1 =
>b.member_id GROUP BY a.ref1 ORDER BY count DESC LIMIT 10
>
>This gives me correct info for the distinct a.ref1 and count fields, and
>produces data for the rest of the fields, but it is not actually that
>member's data. Is this possible to do with one query? If I want to get the
>top 100 referers' data, I don't want to do 100 separate queries. Please
>help!


--
Paul DuBois, [EMAIL PROTECTED]

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


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

Reply via email to