Jump to content

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

no knowing exactly what problem are you trying to solve with that data model seems to me that you are trying to implement some kind of hierarchical thing.... this could give you some ideas

 

http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.