Solved

Access - Match on more than one row

Posted on 2011-03-07
10
297 Views
Last Modified: 2012-08-13
Hi,

In the attached file, please offer a solution as to how I can get a list joined on the A10 and B10, where A9 and B9 are unequal. If it is a one to many pairing, this is viewed as not a match, but it really is not.

Thank you.
Unequal-Map.xlsx
0
Comment
Question by:tahirih
  • 7
  • 2
10 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35061051
You may want to click the "Request Attention" link and ask that the SQL Syntax zone be added to this Q.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 35061079
Don't really follow and I don't know what you are referring to by 'A10' and 'A9'as there doesn't appear be anything with those labels.
0
 

Author Comment

by:tahirih
ID: 35061278
Sorry, yes, I had posted the wrong file, please post an updated one, with the proper field names.

It is easy to create a query where A9 = B9 and A10 = B10.

What I am looking for is where A10 = B10, but A9 <> B9.

Hope this helps.

Unequal-Map.xlsx
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:tahirih
ID: 35061485
Here is the actual code I am using:

SELECT DISTINCTROW [I9 DX].[ICD-9 Dx Code], [I9 DX].[ICD-10 Dx Code], [I10 DX].[ICD-10 Dx Code], [I10 DX].[ICD-9 Dx Code]
FROM [I9 DX] INNER JOIN [I10 DX] ON [I9 DX].[ICD-10 Dx Code] = [I10 DX].[ICD-10 Dx Code]
GROUP BY [I9 DX].[ICD-9 Dx Code], [I9 DX].[ICD-10 Dx Code], [I10 DX].[ICD-10 Dx Code], [I10 DX].[ICD-9 Dx Code];
0
 

Author Comment

by:tahirih
ID: 35061496
Here is the story, and the desired outcome. I have two tables, that have two fields ICD-9 Dx Code and ICD-10 Dx Code in each table (I9 and I10). I am joining on ICD-10 Dx Code, and want to receive a table where the ICD-9 Dx Codes are not the same from I9 to I10 (that is the pairing ot the ICD-10 Dx Code value changes).

The problem is, one I9 code can be mapped to more than one I10, and vice versa. Therefore, when I code, Access/SQL views this as an unequal match, but all that really happens is that there are multiple rows (hope this makes sense).
0
 

Author Comment

by:tahirih
ID: 35061510
The main issue is sorting on the fields so that the code captures that there may be a match on different rows per the I10 match.
0
 

Author Comment

by:tahirih
ID: 35061550
Here is a simple parallel:

Table A
Color       Number
Red          1
Red          2
Blue         3
Orange    4

Table B
Color       Number
Red        1
Red        2
Red       20
Blue       3
Blue       30
Orange   4

Expected Output
Color Number
Red    20
Blue 30
Orange 4

Unfortunately, since this is a one to many in values that are in both tables, this code reads this as Red 1 and Red 2 are also not equal, but they are.

The objective is to output a table where when Table 1 and Table 2 are joined on color, the output table only contains Numbers that are not equal for the join on color in Tables 1 and 2.

Hope this helps.

Thanks

0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 35061658
Do you mean that you want records from table B which are not in table A?

Select B.* from tableB as B left join tableA as A
on B.Color= A.Color and B.[Number] = a.[Number]
where A.color is null
0
 

Author Comment

by:tahirih
ID: 35061782
A blend of both, I have actually used Left and Right joins after my last posting and prior to your last post.

Let me review my work, but yes, you are right, this is a Left/Right Join question.

Thank you
0
 

Author Closing Comment

by:tahirih
ID: 35062382
Thank you.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
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 different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

733 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