|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Pulling Unique Information |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|