Solved

Access - Match on more than one row

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

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now