Forum Moderators: coopster

Message Too Old, No Replies

Returning unique records

         

kwigell

2:18 pm on Aug 8, 2007 (gmt 0)

10+ Year Member



I'm fairly new to PHP and MySQL. I have a MySQL table that contains information on members of a club. I'll oversimplify and say the fields are first name, last name, and email address. Some members may share the same email address, say a husband and wife. So I might have two records, one for the husband and one for the wife, with the same email address.

I need to return records from the table that only return unique email addresses. It doesn't matter which record I return when there is a duplicate email address, but I only want one record for each unique email address.

I can use "SELECT DISTINCT email FROM Members", which gets me one record for each unique email address but omits the name fields. How do I write a SELECT statement that returns the other fields while only returning one record for each unique email address?

I'm sure there is a trivial solution to this. Please forgive a rank newbie. TIA.

justgowithit

2:24 pm on Aug 8, 2007 (gmt 0)

10+ Year Member



SELECT * FROM Members GROUP BY email

Welcome to Webmasterworld, kwigell.

kwigell

2:31 pm on Aug 8, 2007 (gmt 0)

10+ Year Member



Doh! Of course. Thanks much.