-
sql query
i have table thread(tblthread) which has following colmns(Thread_Id,Forun_Id,Thread_Topic,Thread_Description)
in my Forums.aspx in data grid i want to display number of threads in each forum,like
Forums Threads
forum1 10
forum2 22
what sqlquery i have to write,iam little bit confused
how to get count of threads in each forum.
-
Select Forum_Id,SUM(Forum_Id)
From tblthread
Group by Forum_Id
http://www.programmingknowledge.com/
-
i did that and i have the answer but the problem is
the sqlquery which displays the Forum name from (tlbforum) and username from (tbluser_profile)is
sqlQry1="select tblforum.*,tbluser_profile.Nick_Name AS owner,Count(tblthread.Thread_Id)
FROM tblforum INNER JOIN tbluser_profile ON tblforum.User_Id = tbluser_profile.User_Id ORDER BY tblforum.Creation_Date DESC"
now the query which gives me the number of Threads in each forum is
sqlQry2="SELECT count(tblthread.Thread_Id) , tblthread.Forum_Id
FROM tblthread INNER JOIN
tblforum ON tblthread.Forum_Id = tblforum.Forum_Id
GROUP BY tblthread.Forum_Id"
now how to club sqlQry1 and sqlQry2 into one query so that my Datagrid displays
Thread name,thread initiated by,last post in the thread by.
Similar Threads
-
By vaibhavpingle in forum Java
Replies: 0
Last Post: 11-30-2006, 05:58 AM
-
By lightningtechie in forum Database
Replies: 1
Last Post: 02-07-2006, 08:34 AM
-
By Daniel Reber in forum VB Classic
Replies: 0
Last Post: 09-16-2002, 02:50 PM
-
By Ken D. in forum VB Classic
Replies: 2
Last Post: 09-03-2002, 11:25 PM
-
By Jeff Johnson in forum Database
Replies: 3
Last Post: 04-30-2001, 02:42 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks