如果我有以下模式和数据并且正在使用闭包表模式:
+----+----------+------------+--------+
| id | ancestor | descendant | length |
+----+----------+------------+--------+
| 1 | 2 | 2 | 0 |
| 2 | 2 | 12 | 1 |
| 3 | 2 | 13 | 1 |
| 4 | 2 | 14 | 1 |
| 5 | 2 | 15 | 1 |
| 10 | 12 | 12 | 0 |
| 11 | 13 | 13 | 0 |
| 12 | 14 | 14 | 0 |
| 13 | 15 | 15 | 0 |
| 9 | 17 | 20 | 1 |
| 8 | 17 | 19 | 1 |
| 7 | 17 | 18 | 1 |
| 6 | 17 | 17 | 0 |
| 14 | 18 | 18 | 0 |
| 15 | 19 | 19 | 0 |
| 16 | 20 | 20 | 0 |
+----+----------+------------+--------+
我的连接查询返回到我的主表会是什么样子以获取行 id 的所有同级行2
?
+----+----------+------------+--------+
| id | ancestor | descendant | length |
+----+----------+------------+--------+
| 3 | 2 | 13 | 1 |
| 4 | 2 | 14 | 1 |
| 5 | 2 | 15 | 1 |
+----+----------+------------+--------+