i have 2 table, Topic and Comment..

TOPIC
IdTopic
TopicName
CreatedOn
CreatedBy

COMMENT
IdComment
IdTopic(FK)
Comment
ReplayOn
ReplayBy

I want to count all comment where Comment.IdTopic == Topic.IdTopic
cant u help me?
i'm using Linq to sql and C#

thx,

Well i am not a fan of Linq to SQL, i still prefare SQL Server to do the work on an Engine that stil stays in my DB. but to Answer your question.

In SQL this would be enough

SELECT COUNT(IDComment) 
from  Comment c 
inner join Topic t 
on c.IDTOPIC   = idTopic

So you wont need a where Clause because the Inner join does that for you.

Regards

Vuyiswa Maseko

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.