SQLTeam.com | Weblogs | Forums

Joining 3 tables

Hello All,

I am new to the SQL world and with work I use SQL studio.

I have a question, I want to inner join 3 tables.

the table names are Integration.Encounter, Integration.Schedule and Integration.Person.

I have selected the specific columns I want and I coded it like this.

select top 5*

,e.[Person ID]




,s.[Appointment Type]

,s.[No Show Appointment]


The final part of the coding chunk I am having trouble with. I am not sure how to join everything together.

You will see I classified the column pulls by e, s, and p.

schedule table = s

person table = p

encounter table = e

all tables share a similar person ID.

all the help is greatly appreciated.

thank you!

Not sure this will help:

Select ...
  From Integration.Person           p
 Inner Join Integration.Encounter   e On e.PersonID = p.PersonID
 Inner Join Integration.Schedule    s On s.PersonID = p.PersonID
 Where ...

If everything is related by PersonID - the above should work, however - I would think Encounter and Schedule would be related. But not knowing your data it would be almost impossible to determine with the information you have provided.

If possible - could you provide the DDL for each table?