Hello all again,

I've decided against doing it in SQL - I can't work out a query! - so am
doing it in ASP. This is where I'm up to so far -

Function GetSubPages (parentID)

sSQL = "SELECT * FROM tbl_Content_Page WHERE p_parentID = " & parentID
Set oRS = oData.ExecSQL(sSQL, 4, "", "", "")

Do While Not oRS.EOF
Response.Write "id: "&oRS(0)&", title: "&oRS(1)&", parent: "&oRS(3)&"<br>"
Call GetSubPages(oRS(0))
oRS.MoveNext
Loop
                
End Function

I kind of understand what I'm trying to do.. basically keep calling the same
function until there are no more records.

Any thoughts?

Cheers,

Alastair

-----Original Message-----
From: Alastair Moore [mailto:[EMAIL PROTECTED] 
Sent: 22 June 2004 09:27
To: '[EMAIL PROTECTED]'
Subject: [AspClassicAnyQuestionIsOk] slightly OT: selecting "child records"


Hi all,

I've got a database which contains a table with several records.. there's a
sort of parent/child hierarchy going on.. I want to select a specific parent
record and then create a query that'll list all it's child items.. at the
moment I can only select the next level down, not all levels of child
records.. any ideas?

Table definition is like the following -

p_id            - autonumber
p_parentid      - number
p_title - text
p_active        - yes/no

A sample selection of records could be -

1       0       Home            Yes
2       1       About Us        Yes
3       1       Contact Us      Yes
4       2       Company Yes
5       2       Staff           Yes
6       2       History Yes
7       3       Offices Yes
8       3       Location        Yes
9       4       Blah            Yes
10      4       Blah 2  Yes

So if I was to do a select on 2 - about us, I would expect to get the
following results -

4       2       Company Yes
5       2       Staff           Yes
6       2       History Yes
9       4       Blah            Yes
10      4       Blah 2  Yes

Any help with this would be much, much appreciated!

Cheers,

Alastair

 


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
     [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 

Reply via email to