?
Solved

Access - Match on more than one row

Posted on 2011-03-07
10
Medium Priority
?
299 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
[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
  • 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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 2000 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

766 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