Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7573203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:07:23+00:00 2026-05-30T16:07:23+00:00

Above is a screen cap of my schema. The visits table has a list

  • 0

http://imgur.com/uzPGs

Above is a screen cap of my schema.

The visits table has a list of personal ID numbers and ICD is a list of codes that pertain to a certain person. You can see from the junction table that there’s a many-to-many relationship between Visits and ICDTable. I’m trying to make a query that allows a person to type in two records in ICDTable and only return the Visit ID # if a person has both of them. I tried to amend this from a previous query I wrote but I can’t figure out what’s going on. The query doesn’t ‘fail’ per se in that it allows me to search for some things, but it’s obviously wrong. What am I missing? Gracias.

SELECT Visits.ID, Inf.desc, Sore.desc
FROM tblKentuckyCounties 
INNER JOIN 
(
    ICDTable AS Inf 
    INNER JOIN 
    (
        (
            (
                Visits 
                INNER JOIN ICDTable AS InfVisits 
                    ON Visits.ID=InfVisits.VisitsID
            ) 
            INNER JOIN ICDTable AS SoreVisits 
                ON Visits.ID=SoreVisits.ID
        ) 
        INNER JOIN ICDTable AS Sore 
            ON SoreVisits.ICD_IDFK=Sore.ID
    ) ON Inf.ID=Visits.ICD_IDFK
) 
    ON tblKentuckyCounties.ID=Visits.County
WHERE Inf.desc=[enter first term] 
    AND Sore.desc=[enter second term]

thanks for edit.

Ok, so I found out what I needed to do. Below this text is the working query for anyone interested in how to do this sort of thing

SELECT DISTINCT Visits.KHA_ID, Visits.totalCharges
FROM (Visits INNER JOIN (ICDTable INNER JOIN ICDVisitsJxn ON ICDTable.ICD9ID = ICDVisitsJxn.ICD_IDFK) ON Visits.ID = ICDVisitsJxn.VisitsIDFK) INNER JOIN (ICDTable AS ICDTable_1 INNER JOIN ICDVisitsJxn AS ICDVisitsJxn_1 ON ICDTable_1.ICD9ID = ICDVisitsJxn_1.ICD_IDFK) ON Visits.ID = ICDVisitsJxn_1.VisitsIDFK
WHERE (((ICDTable.Description) Like [enter term]) AND ((ICDTable_1.Description) Like [enter another term]));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:07:24+00:00Added an answer on May 30, 2026 at 4:07 pm

    You could divide your query into a subquery containing only ICDVisits and ICDtable (1). In a new query you then join Visits with this subquery twice (2).

    (1)

    SELECT ICDTable.Description, ICDVisits.VisitsIDFK
    FROM ICDTable INNER JOIN ICDVisits ON ICDTable.ICD9ID = ICDVisits.ICD_IDFK;
    

    (2)

    SELECT Visits.ID
    FROM query1 INNER JOIN (query2 INNER JOIN Visits ON query2.VisitsIDFK = Visits.ID) ON
    query1.VisitsIDFK = Visits.ID
    WHERE (((query1.Description) Like 'a') AND ((query2.Description) Like 'b'));
    

    (Query 1 & 2 being the join of ICDVisits and ICDTable).

    Forgot to mention it: You don’t have to use the ID field inside ICDVisitsJxn as a primary key, you could just make the fields VisitsIDFK and ICD_IDFK the primary key. This would avoid duplicated entries.

    Query 1 & 2 (being the same obviously):
    Query1 & 2

    Combined Query:

    Combined Query

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to move my window(with a mouse) above my screen so that
I have a screen that has a few images and one of them has
Above is my schema. What you can't see in tblPatientVisits is the foreign key
here in above screen, i have two linear layouts, one for two TextView and
Please have a look at the above screen shot, I would want to center
I am creating layouts for my app, and as I understand the above screen
The screen shot above show the path for my JPG file-/mnt/sdcard. I try to
As you see in the screen shot above, I have the following expression in
As what I said above. I encountered a problem that I have to dismiss
Hi Guys i have applied Relative positioning to the image as the above screen

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.