Click to See Complete Forum and Search --> : Urgent SQL Query Help


parabiz
November 30th, 2003, 03:11 PM
I am stuck with a very small issue in MS Sql

Here is the scenario:

I have 2 Tables
Table 1 has following Fields: MemberID,MemberName
Table 2 has following Fields: MemberID,CommentID,CommentText

I need the Query to show MemberID,MemberName,TotalComment

If "MemberA" has 4 comments in Table 2 then the result should have "4" in "TotalComment" field

Could anybody help me providing the SQL Query which will Display MemberID,MemberName and TotalPosts as a single Recordset in MS Sql 2000

This is really a urgent

Thank you in advance

raghupathys
December 1st, 2003, 01:29 AM
Try this query

select Table1.*,
(select count(*) from Table2 where Table2.MemberID =
Table1.MemberID) as TotalComment
from Table1

parabiz
December 1st, 2003, 09:00 AM
Hello Friend thank you very much for your kind help :)