|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
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.
Example: 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. |
|
#2
|
|||
|
|||
|
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.
|
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > selecting (partly) distinct rows |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|