August 1st, 2000, 06:49 PM
I don't know how to select rows which have only one column distinct, other columns may be equal. So SELECT DISTINCT doesn't work.
Table has columns 'name' and 'email'.
SELECT DISTINCT name, email FROM table
still gives me rows with same email (but different name). I want only one row in the set for each email.
Do I need some inner join? Please help.
August 3rd, 2000, 08:26 AM
The problem here is that you're kind of asking the database to do more than it knows how to. How is the database supposed to determine _which_ row it should return? If you have three email addresses for one name, how does the DB know which one should be returned? If you add a 'primary_email' column to your table and query and set that on the row that represents a single persons primary email address then you'll get the right result. Alternatively, bring all the results back into your application logic and select whatever row you feel is best.