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 6183999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:27:39+00:00 2026-05-24T01:27:39+00:00

Please take a look at the image.There are 5tables related to appointTable with appointID.

  • 0

Please take a look at the image.There are 5tables related to appointTable with appointID.
Now i need all the data with same appointment id..what should be the joining query?Can any one help me about it?enter image description here

Here is the generated query(I am using Left outer Join)

SELECT     dbo.Appointment.appointment_id, dbo.Appointment.patient_id, dbo.PatientInvestigaiton.investigation_name, dbo.PatientInvestigaiton.investigation_id, 
           dbo.PatientTreatmentMedicine.medecine_id, dbo.PatientTreatmentMedicine.medicinename, dbo.PatientTreatmentMedicine.medicinetype, 
           dbo.PatientFindings.finding_id, dbo.PatientFindings.finding_value, dbo.PatientAdvice.advice_description, dbo.PatientCC.cc_value, dbo.PatientCC.cc_id, 
           dbo.PatientDiagonosis.diagonosis_name, dbo.PatientDiagonosis.diagonosis_id

FROM       dbo.Appointment LEFT OUTER JOIN

           dbo.PatientInvestigaiton ON dbo.Appointment.appointment_id = dbo.PatientInvestigaiton.appointment_id LEFT OUTER JOIN
           dbo.PatientTreatmentMedicine ON dbo.Appointment.appointment_id = dbo.PatientTreatmentMedicine.appointment_id LEFT OUTER JOIN
           dbo.PatientFindings ON dbo.Appointment.appointment_id = dbo.PatientFindings.appointment_id LEFT OUTER JOIN
           dbo.PatientDiagonosis ON dbo.Appointment.appointment_id = dbo.PatientDiagonosis.appointment_id LEFT OUTER JOIN
           dbo.PatientCC ON dbo.Appointment.appointment_id = dbo.PatientCC.appointment_id LEFT OUTER JOIN
           dbo.PatientAdvice ON dbo.Appointment.appointment_id = dbo.PatientAdvice.appointment_id

           where dbo.Appointment.appointment_id='46';
  • 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-24T01:27:40+00:00Added an answer on May 24, 2026 at 1:27 am

    Since appointmnent_id is the primary key of Appointment, this table has a 1:N relationship with all 6 tables.

    This is the case where joining to these 6 tables will produce multiple rows with duplicate data, it’s like a Cartesian Product. For example if (for only one id=46), there are:

    • 3 rows for PatientInvestigation
    • 6 rows for PatientTreatmentMedicine
    • 4 rows for PatientFindings
    • 2 rows for PatientDiagnosis
    • 2 rows for PatientCC
    • 5 rows for PatientAdvice

    you’ll get 3x6x4x2x2x5 = 1440 rows in the result set, while you only need 3+6+4+2+2+5 (+1) = 23 rows. That is 60 times more rows (and with many more columns) than needed.

    It’s better if you do 6 separate queries with one JOIN to one (of the 6) tables in each query (and one more query to get the data from the base table Appointment). And combine the results of the 6 queries in the application code. Example for the base query and the query to join to the first table:

    Base table:

    SELECT 
        a.appointment_id, 
        a.patient_id
    FROM 
        Appointment AS a
    WHERE
        a.appointment_id = 46
    

    Join-1 to PatientInvestigation:

    SELECT 
        pi.investigation_name, 
        pi.investigation_id
    FROM 
        Appointment AS a
          JOIN
        PatientInvestigation AS pi
            ON pi.appointment_id = a.appointment_id
    WHERE
        a.appointment_id = 46
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please take a look at image below All I want is somehow organize Div
Please take a look at this image: alt text http://a.imageshack.us/img21/6190/64635037.png I have a MDI
Please take a look at this page: http://www.carteadenisip.ro/partener/id-753.html - the image is not showing
Please take a look at this link: http://bethhaim.spin-demo.com/ I can't figure out why there
Please take a look at this image: On the top left, notice how HelloWorld
I want a layout like this. Please take a look the image As you
Please take a look at the image am attaching, as you can note its
Please take a look at this image: I apologise for my useless paint ability
Please take a look at the following .htaccess ErrorDocument 404 /404/ RewriteEngine On RewriteRule
Please take a look here: alt text http://img16.imageshack.us/img16/2810/errrp.jpg Why i got that error when

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.