Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 complex query

Author  Topic 

ilimax
Posting Yak Master

164 Posts

Posted - 2009-11-11 : 19:24:33
Visit table
VisID
Nurse
Doc

VisitDetails table
VisID
NursDocID


there is relatiship VisID, and NurseDocID has same ID as Nurse and Doc in Visit table

Select Visit.VisID, VisitDetails.NurseDocID
from Visit INNER JOIN VisitDetails ON
Visit.VisID = VisitDetails.VisID AND (Visit.Nurse = VisitDetails.NurseDocID OR Visit.Doc = VisitDetails.NurseDocID)

I see this my query does not work ...this OR in this part (Visit.Nurse = VisitDetails.NurseDocID OR Visit.Doc = VisitDetails.NurseDocID) will not work ....

I need all records from Visit table that I am sure both Nurse and Doc has own row in VisitDetails table ....






ilimax
Posting Yak Master

164 Posts

Posted - 2009-11-11 : 20:03:18
I can not beleive there is no help for me ....
Go to Top of Page

ilimax
Posting Yak Master

164 Posts

Posted - 2009-11-11 : 22:04:06
or .. if I can make query where I display records only if I have 2 rows in VisitDetails for same visit ...
Go to Top of Page

ilimax
Posting Yak Master

164 Posts

Posted - 2009-11-11 : 22:04:26
I am so blind ... I do not have any idea ...
Go to Top of Page
   

- Advertisement -