LordLanky Posted September 5, 2010 Share Posted September 5, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/212612-linked-lists-in-mysql/ Share on other sites More sharing options...
mikosiko Posted September 5, 2010 Share Posted September 5, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/212612-linked-lists-in-mysql/#findComment-1107621 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.