sql query

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: sql query

  1. #1
    Join Date
    Aug 2006

    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.

  2. #2
    Join Date
    May 2006
    Select Forum_Id,SUM(Forum_Id)
    From tblthread
    Group by Forum_Id


  3. #3
    Join Date
    Aug 2006
    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

  1. Replies: 0
    Last Post: 11-30-2006, 05:58 AM
  2. SQL2000 remote SQL query
    By lightningtechie in forum Database
    Replies: 1
    Last Post: 02-07-2006, 08:34 AM
  3. Return Query Estimate for SQL Server 2000
    By Daniel Reber in forum VB Classic
    Replies: 0
    Last Post: 09-16-2002, 02:50 PM
  4. SQL Query Fails on NT System
    By Ken D. in forum VB Classic
    Replies: 2
    Last Post: 09-03-2002, 11:25 PM
  5. IIF in SQL Query Analyzer
    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
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center