Solved

Access table union - merge data even even non-matches other criteria

Posted on 2014-09-16
1
315 Views
Last Modified: 2014-09-17
I have two tables, "GDW" and "JJHCC" that have the same fields -- User ID and Job Level

I want to create Union by User ID of both tables but I want to use the JJHCC values for Job Level if it exists and only use the GDW information if JJHCC is blank or if that User ID doesn't exist in JJHCC.

GDW has a lot more records than JJHCC so there will be a many that get brought over in the union.

What would the SQL look like for this?

Thanks for your help.

Adam
0
Comment
Question by:aehrenwo
1 Comment
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40325100
SELECT GDW.[User ID], Nz([JJHCC].[Job Level],[GDW].[Job Level]) AS [Job Level]
FROM GDW LEFT JOIN JJHCC ON GDW.[User ID] = JJHCC.[User ID]

UNION ALL

SELECT JJHCC.[User ID], JJHCC.[Job Level]
FROM GDW RIGHT JOIN JJHCC ON GDW.[User ID] = JJHCC.[User ID]
WHERE (((GDW.[User ID]) Is Null));
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question