SunQuest
           MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old August 1st, 2000, 05:49 PM
Marc Boon Marc Boon is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Posts: 4 Marc Boon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old August 3rd, 2000, 07:26 AM
christucker2 christucker2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 81 christucker2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > selecting (partly) distinct rows


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway