mysql query for linked list
问题 I'm using a table that has implemented a single-linked list (id, parent). This implementation has been working well except recently performance has become unbearable since my lists are getting long and I've been querying nodes individually. I found a promising blog on how to query this in a single query. http://explainextended.com/2009/03/25/sorting-lists/ SELECT @r AS _parent, @r := ( SELECT id FROM t_list WHERE parent = _parent ) AS id FROM ( SELECT @r := 0 ) vars, t_list Only thing is I'm