Solved

Reverse of inner join query

Posted on 2004-04-07
5
594 Views
Last Modified: 2008-03-17
The query below does a match between 2 tables and returns 4,100 records. I would now like to run a query that returns the gap which is 472 records (the unmatched records not returned from the HR_CTI table). Basically, I need to inverse the query to find those records that did not match. Hope this makes sense.

SELECT GD_Dump.ID, GD_Dump.EMPLID, GD_Dump.LAST_NAME, GD_Dump.FIRST_NAME, GD_Dump.NAME, GD_Dump.LOCATION, GD_Dump.DESCR, GD_Dump.ADDRESS1, GD_Dump.ADDRESS2, GD_Dump.ADDRESS3, GD_Dump.CITY, GD_Dump.STATE, GD_Dump.POSTAL, GD_Dump.PHONE, GD_Dump.COUNTRY
FROM GD_Dump INNER JOIN HR_CTI ON (GD_Dump.FIRST_NAME = HR_CTI.Fname) AND (GD_Dump.LAST_NAME = HR_CTI.Lname);
0
Comment
Question by:dgelinas
[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
  • 2
5 Comments
 
LVL 54

Expert Comment

by:nico5038
ID: 10775310
In the query editor double click the join lines and make one table "leading"
Next make the unique ID of the "optional" table to be compared with "Is Null" (without quotes)

This will give the half of the outer join needed as all non-matching from the leading table will appear.

Next do the same "the other way around" to get the second half.

A UNION query can be used when you want the complete set.

Clear ?

Nic;o)
0
 
LVL 6

Author Comment

by:dgelinas
ID: 10775323
I was hoping for an easier solution in SQL. I'll try what you suggest but it sounds a little hairy.
0
 
LVL 54

Accepted Solution

by:
nico5038 earned 250 total points
ID: 10775444
It's all SQL, just gave the directions to use the graphical query editor as it'is easy to see the relation and to know what main key need to be tested for being Null.

Like
TableX -> TableY
test ID from TableY to be null to get the non-matching TableX rows
TableX <- TableY
test ID from TableX to be null to get the non-matching TableY rows

Nic;o)
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 10775463
to find the records in GD_DUMP that ARE NOT in HR_CTI:

SELECT GD_Dump.ID, GD_Dump.EMPLID, GD_Dump.LAST_NAME, GD_Dump.FIRST_NAME, GD_Dump.NAME, GD_Dump.LOCATION, GD_Dump.DESCR, GD_Dump.ADDRESS1, GD_Dump.ADDRESS2, GD_Dump.ADDRESS3, GD_Dump.CITY, GD_Dump.STATE, GD_Dump.POSTAL, GD_Dump.PHONE, GD_Dump.COUNTRY
FROM GD_Dump LEFT JOIN HR_CTI ON (GD_Dump.FIRST_NAME = HR_CTI.Fname) AND (GD_Dump.LAST_NAME = HR_CTI.Lname) where HR_CTI.FNAme is Null;

you can also build this easily with the Access Query Builder, using the UnMatched Query Wizard (Query Builder/New/UnMatched Query Builder)

AW
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

734 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