Jump to content

Linked Lists in mySQL?


LordLanky

Recommended Posts

Hi All,

 

I have a linking table in my database that looks something like this:

 

TO |  FROM         

 

1, 4

1, 7

2, 3

2, 9

3, 7

3, 8

 

Basically - it's a list of IDS where two records are associated. I.e., the top row says that ID 1 is related to ID 2. The second row says that ID 1 is related to ID 7. It's a -many-to-many kind of thing - many 'froms' join with many 'tos', and vice-versa.

 

What i am trying to do is make a 'journey' through this data. I.e. make a linked list of all the following IDs from a single given one. In PHP I would simply take one id, find the related id, then run another query - over and over until the chain runs out.

 

I was wondering if there is a clever mysql way of doing this?

 

many thanks!

Link to comment
https://forums.phpfreaks.com/topic/212612-linked-lists-in-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.