Unwanted cartesian results (a chronic problem for me!)

Posted on 2008-06-20
Medium Priority
Last Modified: 2013-12-25
I keep getting unwanted cartesian results in my join, no matter how long I work at this.  (Access SQL seems to give me a harder time than SQL Server.)

I want all records from the patient table and only one matching record each from the insurance table.  (There are multiple matches in the table.)
EpiscopalPatient.VisitNumber, EpiscopalPatient.MedRecordNumber,
FROM EpiscopalPatient 
LEFT JOIN EpiscopalInsurance 
ON EpiscopalPatient.MedRecordNumber = EpiscopalInsurance.MedicalRecordNumber

Open in new window

Question by:AmyFPA
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

Expert Comment

ID: 21832165
Does it matter which match it pulls from your insurance table?
LVL 27

Expert Comment

ID: 21832202
<There are multiple matches in the table>
Are you saying that  there can be more than one row in EpiscopalInsurance for a single MedicalRecordNumber?
If not then the inclusion of Visit Number in the Select list will result in one row for every PatName/Visit combination in EpiscopalPatient
LVL 93

Accepted Solution

Patrick Matthews earned 500 total points
ID: 21832203
EpiscopalPatient.VisitNumber, EpiscopalPatient.MedRecordNumber,
Max(EpiscopalInsurance.GuarName) AS Guardian
FROM EpiscopalPatient
LEFT JOIN EpiscopalInsurance
ON EpiscopalPatient.MedRecordNumber = EpiscopalInsurance.MedicalRecordNumber
GROUP BY EpiscopalPatient.PatName,
EpiscopalPatient.VisitNumber, EpiscopalPatient.MedRecordNumber

Author Closing Comment

ID: 31469196
You're wonderful!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

777 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