I have a question about building a linked list structure in mysql/php.
I have a database laid out like:
id name next (references next row's id) start
1 example1 2 1
2 example2 5 0
5 example3 4 0
4 example4 NULL 0
Basically, I want to start with the row that has the value of column 'start' set to 1, and then continue to the row with the id listed in the current row's 'next' until next=NULL. This means a lot of separate queries to grab the information from each row and then query the db again for the information from the next row. The best way that I can think of doing this would be to query the database just once and store the information in some type of array structure, and then re-order it using a php loop. This can potentially require a lot of overhead for PHP...
My question is really this: Is there a better way to accomplish the task above (perhaps a magical mysql query) or a better/similar structure that would accomplish the same thing? I can do it with an integer value and place the item in it's appropriate integer place, but that would require an UPDATE query to every item after an inserted item in a list to add one to it's int value and show that it's gone 'down' a spot in the list. To really simplify here: How do you order items in mysql? Any help is appreciated!