From: Peter Brawley Date: August 30 2006 9:32pm Subject: Re: Group By question List-Archive: http://lists.mysql.com/mysql/201522 Message-Id: <44F603F6.2040904@earthlink.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=======AVGMAIL-44F603F648A4=======" --=======AVGMAIL-44F603F648A4======= Content-Type: multipart/alternative; boundary=------------080503050803080205090809 --------------080503050803080205090809 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Chris, />I would like to query all rows that have more >than one person with the same email address. / select id,count(emailaddr) as howmany from tbl t1 join tbl t2 using(emailaddr) group by id having howmany>1; PB ----- Chris W wrote: > I have a table of people with one of the fields being the email > address. I would like to query all rows that have more than one > person with the same email address. For example if the data were > like this... > > A 123@stripped > B 456@stripped > C 984@stripped > D 123@stripped > E 456@stripped > F 321@stripped > > The query would return row A, D, B, and E, in that order. It would > not return C or F > --------------080503050803080205090809 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Chris,

>I would like to query all rows that have more
>than one person with the same email address.


select id,count(emailaddr) as howmany
from tbl t1 join tbl t2 using(emailaddr)
group by id
having howmany>1;

PB

-----

Chris W wrote:
I have a table of people with one of the fields being the email address.  I would like to query all rows that have more than one person with the same email address.   For example if the data were like this...

A 123@stripped
B 456@stripped
C 984@stripped
D 123@stripped
E 456@stripped
F 321@stripped

The query would return row A, D, B, and E,  in that order.  It would not return C or F

--------------080503050803080205090809-- --=======AVGMAIL-44F603F648A4======= Content-Type: text/plain; x-avg=cert; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-Description: "AVG certification" No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.11.7/433 - Release Date: 8/30/2006 --=======AVGMAIL-44F603F648A4=======--