[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

shapper

3/29/2007 10:26:00 PM

Hello,

I have 4 tables as follows:
[Document] > DocumentId (PK)
[Comment] > CommentId (PK), DocumentId (FK)
[Rate] > RateId (PK), CommentId (PK)
[RateNames] > RateId (PK), RateName (NVARCHAR(200))

I need to get all RateIDs from Rate which are related to Comments that
are related to a given DocumentId.

Then, having those RateID's, I want to return the RateID's with the
correspondent RateNames taken from table RateNames.

How can I do this?

Thanks,
Miguel

1 Answer

Tom Cooper

3/29/2007 10:54:00 PM

0

Select r.RateId, rn.RateName
From Comment c
Inner Join Rate r On c.CommentId = r.CommentId
Inner Join RateNames rn On r.RateId = rn.RateId
Where c.DocumentId = <whatever>

Tom

"shapper" <mdmoura@gmail.com> wrote in message
news:1175207174.020680.213580@p15g2000hsd.googlegroups.com...
> Hello,
>
> I have 4 tables as follows:
> [Document] > DocumentId (PK)
> [Comment] > CommentId (PK), DocumentId (FK)
> [Rate] > RateId (PK), CommentId (PK)
> [RateNames] > RateId (PK), RateName (NVARCHAR(200))
>
> I need to get all RateIDs from Rate which are related to Comments that
> are related to a given DocumentId.
>
> Then, having those RateID's, I want to return the RateID's with the
> correspondent RateNames taken from table RateNames.
>
> How can I do this?
>
> Thanks,
> Miguel
>