"recursive" mysql queries?
- Started
- Last post
- 1 Response
- bry
i've got a mysql table where the rows have a doubly linked-list structure to them (each row has a 'prev' and 'next' column that points to the previous or next row -- this is to make arbitrary ordering of rows possible).
currently, to display the table in that arbitrarily specified order, i have to get PHP to do one query to obtain the "start" row, then grab that row's 'next' value to obtain the next row's id, then grab _that_ row's 'next' value, and so on. this is the only way i know how to go about it and it doesn't strike me as very computationally efficient.
is there any way i can use mySQL's ORDER BY clause to condense all those multiple queries into a single query that crawls its way through all those 'next row' values and returns the arbitrarily ordered result set? or do i have to come up with some kind of fancy "recursive" query that crawls around the table until it's found all the rows in the table?
- UndoUndo0
why not crawl through the result resource?