A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

eliminate duplicates



 
 
Thread Tools Display Modes
  #1  
Old May 18th, 2007, 03:52 PM posted to microsoft.public.access.queries
Holly
external usenet poster
 
Posts: 187
Default eliminate duplicates

I have a table with 7 columns of team member names. I need a count of all
team members, but need to eliminate duplicate names. How do I query seven
different columns in a table and eliminate the dups?
  #2  
Old May 18th, 2007, 05:35 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default eliminate duplicates

First fix your table structure so that names are all in the same field
(column to you).
Why are they in didderent fields - is each field for a different position?
Then use a field for name and a field named position that has position as
data in the field.
--
KARL DEWEY
Build a little - Test a little


"holly" wrote:

I have a table with 7 columns of team member names. I need a count of all
team members, but need to eliminate duplicate names. How do I query seven
different columns in a table and eliminate the dups?

  #3  
Old May 18th, 2007, 05:41 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default eliminate duplicates

On Fri, 18 May 2007 07:52:02 -0700, holly
wrote:

I have a table with 7 columns of team member names.


Well... then you have an incorrectly designed table. That's spreadsheet
thinking, not relational thinking!

What is the rest of the structure of this table? What is its purpose?

I need a count of all
team members, but need to eliminate duplicate names. How do I query seven
different columns in a table and eliminate the dups?


A "Normalizing Union" query can do this. You need to use the SQL window to do
it, and I don't know your fieldnames of course, so you'll need to adapt this.
Create a new query without selecting any table, and then choose View... SQL;
you'll see a text window with just the word SELECT; in the upper left.

Edit it to

SELECT Name1 FROM yourtable WHERE Name1 IS NOT NULL
UNION
SELECT Name2 FROM yourtable WHERE Name2 IS NOT NULL
UNION
etc through all seven fields

This will assemble all the names from all seven fields in all records and will
remove duplicates.

You should really consider normalizing your table structure to avoid this
problem! "Fields are expensive, records are cheap" - rather than having one
(guessing here) Team table with seven membername fields, you should consider
three tables:

Teams
TeamID
information about the team as a whole

Players
PlayerID
LastName
FirstName
other biographical data

TeamPlayers
TeamID link to Teams
PlayerID link to Players
Position or other info about this player on this team

John W. Vinson [MVP]
 




Thread Tools
Display Modes

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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:49 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.