Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to make a efficient order by

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
0
0
US
I have a table that has 2 fields I want to order by<br>but has relations to another 2 <br><br>for example lets say we had<br><FONT FACE=monospace><br>HI LI&nbsp;&nbsp;HP&nbsp;&nbsp;LP<br>1 ¦ 1 ¦ 0 ¦ 0<br>2 ¦ 1 ¦ 0 ¦ 0<br>3 ¦ 1 ¦ 0 ¦ 0<br>3 ¦ 2 ¦ 3 ¦ 1<br>3 ¦ 3 ¦ 3 ¦ 2<br>3 ¦ 4 ¦ 3 ¦ 2<br>3 ¦ 5 ¦ 3 ¦ 1<br>4 ¦ 1 ¦ 0 ¦ 0<br>4 ¦ 2 ¦ 4 ¦ 1<br><i>H=Header, L=Leaf, I=ID, P=Parent</i><br></font><br><br>ok I want that kind of order about, parents cominning first, then it's children, then the children of the other child before it gets to the next parent for example the above could be<br><FONT FACE=monospace><br>(1,1)<br>(2,1)<br>(3,1)<br>&nbsp;&nbsp;&nbsp;¦<br>&nbsp;&nbsp;&nbsp;-(3,2)<br>&nbsp;&nbsp;&nbsp;¦&nbsp;&nbsp;&nbsp;¦<br>&nbsp;&nbsp;&nbsp;¦&nbsp;&nbsp;&nbsp;-(3,3)<br>&nbsp;&nbsp;&nbsp;¦&nbsp;&nbsp;&nbsp;-(3,4)<br>&nbsp;&nbsp;&nbsp;-(3,5)<br>(4,1)<br>&nbsp;&nbsp;&nbsp;¦<br>&nbsp;&nbsp;&nbsp;-(4,2)<br></font><br>I want to read down as if it were a fully expaned treee, and have it sorted like it is above, so that when I read row by row of the recordset, I can just read it's HP/LP and see if I need to tab it over, or what relations to the one above it to set in my ASP, that way I wont have to figure out how to create a Rescursive VBscript function, that might require 4 or 5 open recordsets during a stack.<br><br>if anyone knows how I Can use the OrderBy to help me acheive this let me know. ( I Can change the 0,0 to like 1,0 and 2,0 if that helps in the process ) <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
In Oracle you can write like this:<br>SELECT * FROM you_table<br>CONNECT BY PRIOR HI=HP AND PRIOR LI=LP<br>START WITH HI=1 AND LI=1;<br>Good luck! <p>Eduard Stoleru<br><a href=mailto:e_stoleru@yahoo.com>e_stoleru@yahoo.com</a><br><a href= > </a><br>
 
I already have it figured out, its not throught the Order by HP, LP (even tho that helps to start with) but I load everything into an array using Getrows, and I go from there. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top