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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find all items in a list/table that are related

Status
Not open for further replies.

jw45

Programmer
May 27, 2005
56
US
I have ‘inherited’ a table with data structured as such:
All data is in one table… no joins.

Item Item Qty
11 21 1
21 31 2
21 41 1
21 63 14
21 76 5
63 55 2
41 85 1.5
51 96 2
85 25 4


I want to be able to find all items in the table that has an association with an item in the first column. i.e. if I choose 11 in the first column then it would return 21 from the second column. Then I want to use 21 to find all numbers in the second column related to 21. Use that list in the first column to find items in the second and so on. I do not know how many iterations of this that can occur but should be less than 10 max.

After I find all the relations, I would like a way to display the data on a form like:
Item Qty
11
21 1
31 2
41 1
85 1.5
25 4
63 14
55 2
76 5


Can anyone point me in the right direction?

Thanks,
JW
 
look at self joins
to get the it to display on a form like you ask look at a treeview
could easily load the treeview using a recursive call to a function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top