Re: Just another SQL Query



John wrote:
Hello again,

I have an other SQL Query Problem. I have a table 'Visit' with the
columns 'Reason', 'PersonA' and 'PersonB'. These columns are Guids.
Then I have an other table 'Persons' with a column 'ID' (Guid),
'Name' and 'Date of birth'. Now I need a Query that gives me this
result: Visit.Reason and the name of PersonA and PersonB.
I tried it with two 'inner join' but that doesn´t work...

Two inner joins should work. Perhaps you should clarify "doesn't work".

select v.Reason,v.PersonA,a.[Name] as NameOfA,
v.PersonB, b.[Name] as NameOfB
FROM Visit v inner join Persons a on v.PersonA=a.ID
inner join Persons b on v.PersonB = b.ID

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


.