In MySQL, how do I select distinct records, but still select more data? In MySQL, I want to select emails, firstname, date, etc from past orders where the email is unique. I
then want to show other fields for that same row with the first match (the oldest) in the database. For example:
Example Real Data:
ID,Email, Name,ORDER DATE
1,mark@domain.com,Mark,12-2-09
2,popular@domain.com,Jim,1-5-10
3,Mark@domain.com,Mark,2-3-10
4,test@test.org,Bob,2-9-10
5,mark@domain.com,Mark,3-1-10
Of the above data, I only want it to show distinct my email, but the other info still there:
Example Distinct Data:
ID,Email,Name,ORDER DATE
1,mark@domain.com,Mark,12-2-09
2,popular@domain.com,Jim,1-5-10
4,test@test.org,Bob,2-9-10
Do you know the correct MySQL query for this?
Thanks! |