Confirm that my union is between matching objects

G

Guest

In the query below, the sub-queries "TRI OCS CPA join" and "PAR3417 results
vs detects by works" do not have the same structure; however, the things
selected from them (and unioned as far as I know) do have the same structure.
I tried a similar query out and it did seem to union properly but I would
like to confirm that I actually am unioning things with matching structure.
The script on either side of the union is the same except for the first is a
left join and the other a right join.

SELECT TOC.[Works_number], TOC.[Works_name], TOC.[Source_ name],
TOC.[TRI.Expr1], TOC.[OCS.Expr1], TOC.[Expr1], PAR.[Expr1]
FROM [TRI OCS CPA join] TOC LEFT JOIN [PAR3417 results vs detects by works]
PAR
ON TOC.[Works_number]=PAR.[Works_number]
UNION
SELECT TOC.[Works_number], TOC.[Works_name], TOC.[Source_ name],
TOC.[TRI.Expr1], TOC.[OCS.Expr1], TOC.[Expr1], PAR.[Expr1]
FROM [TRI OCS CPA join] TOC RIGHT JOIN [PAR3417 results vs detects by works]
PAR
ON TOC.[Works_number]=PAR.[Works_number];

Thanks,
Pat
 
J

John Spencer

It looks good to me. As long as you fields are in the same order and
are of the same type there should be now problem.

One thing, UNION returns unique records, so if you want all records
returned you might want to use UNION ALL as the conjunction between the
queries.



'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 

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