給定一組嵌套在mysql中這樣獲取嵌套組的祖先那裏條件
+-------------+----------------------+-----+-----+------+
| category_id | name | lft | rgt | rank |
+-------------+----------------------+-----+-----+------+
| 1 | ELECTRONICS | 1 | 20 | 99
| 2 | TELEVISIONS | 2 | 9 | 50
| 3 | TUBE | 3 | 4 | 25
| 4 | LCD | 5 | 6 | 25
| 5 | PLASMA | 7 | 8 | 25
| 6 | PORTABLE ELECTRONICS | 10 | 19 | 50
| 7 | MP3 PLAYERS | 11 | 14 | 25
| 8 | FLASH | 12 | 13 | 10
| 9 | CD PLAYERS | 15 | 16 | 25
| 10 | 2 WAY RADIOS | 17 | 18 | 20
我怎樣可以得到如祖先:「閃光」,其中條件等級爲> = 50,< = 99 LIMIT 1排序由lft DESC。 所以其結果將是
+-------------+----------------------+-----+-----+------+
| category_id | name | lft | rgt | rank |
+-------------+----------------------+-----+-----+------+
| 6 | PORTABLE ELECTRONICS | 10 | 19 | 50
可視化參考此鏈接 http://mikehillyer.com/media//categories.png
在模型中,除了圖片之外什麼指示「便攜式電子設備」是「快閃」的祖先? – Anton
這是左邊的列.. – Harts
那麼如何解釋這些lft,rgt? – Anton