Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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 March 9th, 2005, 04:50 AM
Registered User
 
Join Date: Jun 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default display the resultset of 2 table join

Hi,
I have 2 tables in my db category and subcategory
category tbl fields: catID CatName
subcategory tbl fields:subID CatID SubName
the two tables are joined through the common 'catID' field.
I want to display the records in 3 columns and in each column the category is shown +
its related subcategories.
like this:
Category1 Category2 category3
subCat1 subcat1 subcat1
subcat2 subcat2 subcat2
subcat3
I use the following code but it returns all the cats and subcats in a row.
How should I writer my sql query and the page code?

<%
Rs3.open "select * from category left outer join subcategory on subcategory.catid=category.catid",Conn,3,3
%>

<table width="430" cellpadding="2" cellspacing="2">

                        <%
                          Dim NumRows,Index
NumRows = -2
index = 0
rs_NumRows = rs_NumRows + NumRows
startrw = 0
endrw = index
numberOFColumns =4
numrows = -1
while((numrows <> 0) AND (Not rs3.EOF))
      startrw = endrw + 1
    endrw = endrw + numberOFColumns
    num=num+1
 while ((startrw <= endrw) AND (Not rs3.EOF))

                        %>
                        <td>
        <table width="80" border="0" cellpadding="0" cellspacing="3" class="text">
                          <tr>
                                <td><p align="center">
                                <img src="images/<%=rs3("image")%>" width="61" height="46"></td>
                            </tr>
                            <tr>
                                <td><p align="center"><a href="show.asp?catid=<%=rs3("catid")%>"><%=rs3("ca tname")%>(<%'=rs3("card_count")%>)</a><a href="show.asp?catid=<%=rs3("catid")%>&subid=<%=rs 3("subid")%>"><%=rs3("subname")%></a></p></td>
                            </tr>
                            </table>
        </td>
                            <%


startrw = startrw + 1
    rs3.movenext
    wend
%>
</tr>
    <%
 numrows=numrows-1
 Wend
%>





Similar Threads
Thread Thread Starter Forum Replies Last Post
table join debbiecoates SQL Server 2000 2 July 2nd, 2008 01:39 PM
display the resultset of 2 table join keyvan Classic ASP Databases 0 March 7th, 2005 09:34 AM
call resultset in join query zaman1111 JSP Basics 2 November 5th, 2004 08:44 AM
could i join function(return table) with a table alyeng2000 SQL Server 2000 6 September 30th, 2004 07:23 AM
outer join on same table roog SQL Language 4 September 30th, 2004 05:31 AM





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