Union Assistance Requested

G

Guest

I have 2 Excel Spreadsheets. One has Social Security Number, Name, Location,
Series, Grade, Hours 1, Hours 2, Percentage of Hours 2. The other
spreadsheet has Social Security Number, Name, Race, Age, Date of service and
retirement code. How would I Union these together?

The trouble I have is that I have fields that different. I need the Social
Security Numbers to match up and the rest of the data that matches that
specific Social Security Number to append to that data string.

Thank you in advance



oh, by the way, TD wrote: Subject: RE: Help...Merging 2 reports with 1
field that contains data that matc
Date: 8/18/2006 9:56 AM PST
From: td



Hello Dacid
Why do you have multiple tables containing the same type of data?
Anyway...
Yes! You can use a report based on a UNION. However, there is a problem in
that the fields for each part of the Union must parallel each other eg
SELECT Fld1,Fld2,Fld3 FROM tblA
UNION
SELECT FldA,FldB,FldC FROM tblB
The field counts in each SELECT must match and the corresponding fields must
be of the same type of data.
Hope this helps
td




Dave
 
G

Guest

I do not see the need for a UNION query but just use an INNER JOIN on Social
Security Number.
 
J

John Vinson

I have 2 Excel Spreadsheets. One has Social Security Number, Name, Location,
Series, Grade, Hours 1, Hours 2, Percentage of Hours 2. The other
spreadsheet has Social Security Number, Name, Race, Age, Date of service and
retirement code. How would I Union these together?

You wouldn't. A UNION query joins tables "end to end" - if you have
100 records in tableA and 200 in tableB, a UNION query will give you
all 300 records in one recordset.

You want a JOIN query:

SELECT Spreadsheet1.*, Spreadsheet2.*
FROM Spreadsheet1 INNER JOIN Spreadsheet2
ON Spreadsheet1.[Social Security Number] = Spreadsheet2.[Social
Security Number];

John W. Vinson[MVP]
 
G

Guest

Thank you for your assistance however I would like to trouble you for one
more question. If I use a inner join, will I end up with a sheet with all
the data from both sheets lined up up by the social security number?

Thank you in advance.

Dave


John Vinson said:
I have 2 Excel Spreadsheets. One has Social Security Number, Name, Location,
Series, Grade, Hours 1, Hours 2, Percentage of Hours 2. The other
spreadsheet has Social Security Number, Name, Race, Age, Date of service and
retirement code. How would I Union these together?

You wouldn't. A UNION query joins tables "end to end" - if you have
100 records in tableA and 200 in tableB, a UNION query will give you
all 300 records in one recordset.

You want a JOIN query:

SELECT Spreadsheet1.*, Spreadsheet2.*
FROM Spreadsheet1 INNER JOIN Spreadsheet2
ON Spreadsheet1.[Social Security Number] = Spreadsheet2.[Social
Security Number];

John W. Vinson[MVP]
 
J

John Vinson

Thank you for your assistance however I would like to trouble you for one
more question. If I use a inner join, will I end up with a sheet with all
the data from both sheets lined up up by the social security number?

Yes.

Why not *try it*?

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top