Re: SQL Question
Posted in 2003
Rajesh Kapur wrote: > I have a table where the hierarchy is built by storing the parent_id in the > same table.... > > id, > parent_id > .... other fields > > Can someone suggest an SQL statement that will list the entire hierarchy as > follows > > id1 > id1.1 > id1.2 > id1.2.1 > id1.2.2 > id1.2.3 > id1.2.3.1 > id1.3 > id1.4 > id2 > .... Check the archives. I've posted snippets of SPL code in 1998 & 2000 and possibly before that in 4GL. You can write recursive code in SPL or 4GL, just be careful that you don't descend too many levels. Cheers, -- Mark. +----------------------------------------------------------+-----------+ | Mark D. Stock mailto:mdstock@MydasSolutions.com |//////// /| | Mydas Solutions Ltd http://MydasSolutions.com |///// / //| | +-----------------------------------+//// / ///| | |We value your comments, which have |/// / ////| | |been recorded and automatically |// / /////| | |emailed back to us for our records.|/ ////////| +----------------------+-----------------------------------+-----------+ sending to informix-list