Solved

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

Posted on 2014-09-16
1
316 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

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.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

732 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