recursion

1. Member
Join Date
Dec 1969
Posts
84

## recursion

Hi,<BR><BR>I interested in figuring out how to build a recursive query in SQL.<BR><BR>I am trying to compare all the records in a table against all the other records in the same table. I understand that to do this I should have a recursive function that builds a tree of all combinations. I have seen how to do this in javascript, but I&#039;m a bit lost on how to make a stored procedure do this.<BR><BR>For example, if TABLE1 has 3 records, I want to create another table that has all various combinations of IDs of TABLE1: (I know that the number of records in the resulting table will be large, but that&#039;s something I can deal with).<BR><BR>1<BR>1,2<BR>1,3<BR>2<BR>2,3<BR>3<BR> 1,2,3<BR>(the order of the combinations is unimportant, so duplicates can be eliminated 1,2 and 2,1 are the same to me.)<BR><BR>My skills are not in OOP and/or recursion, so I&#039;m looking around for some advice. Any puzzle masters out there want to point me in the right direction. (I&#039;m not a student working on a homework assignment, so I don&#039;t need a complete answer, I&#039;m a developer trying to figure out if this solution will be easier to implement than an iterative algorithm - :-)).<BR><BR>Yes, I&#039;m also looking a building a separate COM object (which an easier solution, but also has its own limitations), but it&#039;s the SQL solution that is eluding me.<BR><BR>If you want to contact me directly, webmaster@landandfarm.com.<BR><BR>Thanks

2. Member
Join Date
Dec 1969
Posts
84

## RE: recursion

I found this:<BR><BR>http://www.sqlteam.com/item.asp?ItemID=1602

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•