MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 8th, 2004, 02:12 PM
homchz homchz is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 2 homchz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Pulling Unique Information

I have a table where I have


id|city|state|sales_person|sales_email|

Our sales people each cover many cities, but I want to beable to pull just the
Unique Names and Email Addresses from this table, where there are many
duplicates.

Not looking for anyone to write he query I am just having a hard time finding the
command if it is possible. As I belive Unique is use in Table Building Only.

BTW: I am pretty new at this.

Thanks
Josh

Reply With Quote
  #2  
Old July 8th, 2004, 04:21 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Try "SELECT DISTINCT sales_person, sales_email FROM table".

If you've got a lot of duplicate data, incidentally, you might want to look into normalizing it a smidgin. For example, you might consider having a salesperson table that contains the name and email and a locations table that contains cities and states. Then either the locations table or a table with foreign keys to both of the other tables would link salespeople to locations. Doing this prevents you from having to update a bunch of rows if somebody's email address changes, for example, and it also makes selecting distincts much easier -- if you have no duplicates, it becomes a simple select out of the salesperson table.
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
  #3  
Old July 12th, 2004, 07:23 AM
homchz homchz is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 2 homchz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the info, I did find DISTINCT later on and it worked fine, I ended up adding the Salespeople to my Employee Table, but have yet to figure out how to link them back to the territories. Though I might try a numerical territorial system to try an join the tables. I am slightly embarrased to say Foregin Keys are eluding me at the time, but I'll keep plugging away at it.


Thanks again
Josh

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Pulling Unique Information


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 6 hosted by Hostway
Stay green...Green IT