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
Solved

Access - Match on more than one row

Posted on 2011-03-07
10
296 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
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.

 

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

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

828 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