我甚至不知道如何标题这个问题,但我希望这是有道理的。
我有三张桌子:
第3个表有两列:
注意:
我需要转储第3个表的视图,完全展开每个组的所有成员,包括嵌套组,转储组路径,以及处理无限循环。希望这个例子清楚地表明:
| ID | user_name |
|----|-----------|
| 1 | one |
| 2 | two |
| 3 | three |
| 4 | four |
| 5 | five |
| ID | group_name |
|----|------------|
| 6 | six |
| 7 | seven |
| 8 | eight |
| 9 | nine |
| 10 | ten |
| group_ID | member_ID |
|----------|-----------|
| 6 | 1 |
| 6 | 2 |
| 6 | 3 |
| 7 | 4 |
| 7 | 5 |
| 8 | 1 |
| 8 | 9 |
| 8 | 10 |
| 9 | 5 |
| 10 | 1 |
| 10 | 8 |
| group_ID | user_ID | user_name | group_path
|----------|---------|-------------|------------
| 6 | 1 | one | six
| 6 | 2 | two | six
| 6 | 3 | three | six
| 7 | 4 | four | seven
| 7 | 5 | five | seven
| 8 | 1 | one | eight
| 8 | 5 | five | eight > nine
| 8 | 1 | one | eight > ten
| 8 | | [recursive] | eight > ten > eight
| 9 | 5 | five | nine
| 10 | 1 | one | ten
| 10 | 1 | one | ten > eight
| 10 | 5 | five | ten > eight > nine
| 10 | | [recursive] | ten > eight > ten