Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 25th, 2004, 09:01 AM
Registered User
 
Join Date: Sep 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need Help to Display Records from 3 Tables

Hi, i hope you all good people there can help me out...here's my problem

i have 4 SQL tables: Topic, Category, Headings and Comments.
each tables has a one-many relationship. ie a Topic can have one or many Category fields, each category field can have non or many headings and each heading can have non or more comments.

Function AddTable()
        Dim rs As ADODB.Recordset
        Dim SQL As String
        Dim heading As Long
        rs = OpenRs("select TOP 100 PERCENT StormCategory_1.CategoryName, StormHeading_1.uID, StormHeading_1.Heading, StormHeading_1.Idea from StormCategory_1 INNER JOIN StormHeading_1 on StormCategory_1.uid = StormHeading_1.BelongCategoryID WHERE StormCategory_1.BelongToTopic = '" & topic & "' ORDER BY StormCategory_1.CategoryName")
        With rs
          Dim oldcategoryname
           If Not .EOF Then
             Do While Not .EOF
              If .Fields("CategoryName").Value <> oldcategoryname Then
                oldcategoryname = .Fields("CategoryName").Value
       Response.Write("<table id=table2 border=1 width=550 colspan=0 rowspan=0 bgcolor=blue>")
       Response.Write("<tr><td><h2>" & .Fields("Categoryname").Value & "</h2>")
       Response.Write("<table id=table3 border=1 width=100% colspan=0 rowspan=0 bgcolor=white>")
             End If
       Response.Write("<tr>")
      heading = rs.Fields("uID").Value
     Response.Write("<td><a style='color:blue; text-decoration:none' href=idea.aspx?HeadingID=" & heading & ">" & .Fields("Heading").Value & "</a></td></tr>")
         .MoveNext()
        If .EOF Then
      Response.Write("</td></tr></table></table>")
                    Else
  If .Fields("CategoryName").Value <> oldcategoryname Then

      Response.Write("</td></tr></table></table>")

       End If
     End If
    Loop
  End If
.Close()
AddTableDR = Nothing
End With
SqlConnection2.Close()
End Function

the code above allows me to display records from two tables, ie Category and Heading. but now my problem is i need to add comments to the headings and in turns display the comments under heading.
i would the category, heading to be displayed whether or not there are any comments on them.

is it possible to have a single query and then use nested loops to display the records??
or do i have to use two different sql command???

i hope you all out there can help me out with this problem....
thank you..






Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve records from 2 tables snufse SQL Server 2000 7 January 29th, 2008 04:31 AM
Compare records between two tables jaaboston Access VBA 1 December 21st, 2006 05:35 AM
deleting records in linked tables tico31pl Access 4 May 18th, 2006 04:10 PM
how to join all records from both tables? yixchen Access 4 January 4th, 2006 01:36 PM
Adding records to Tables lgpatterson Access VBA 6 March 20th, 2005 07:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.