これは非常に簡単だと確信していますが、私はデータベース関連が非常に苦手です...
Access 2003 に次のテーブルがあります。
title | id
/root | 1
/root/x | 2
/root/x/y | 3
/root/x/y/z | 4
/root/x/a | 5
/root/x/a/b | 6
つまり、一連のノードと ID 番号 - /root/x が /root/x/y の親であることがわかります。親の ID とともに、すべてのノードのリストを持つ別のテーブルを作成したいと思います。すなわち:
id | parent id
1 | -
2 | 1
3 | 2
4 | 3
5 | 2
6 | 5
以下は、親のIDと値を提供します:
select id, left(c.title, instrrev(c.title, "/")-1) as parentValue from nodeIDs
収量
id | parentNode
1 |
2 | /root
3 | /root/x
4 | /root/x/y
5 | /root/x
6 | /root/x/a
これらの親ノードの値ではなく ID を返すために必要な追加の手順は何ですか?つまり、最後のテーブルで「/root」の代わりに「1」を返しますか?
どうもありがとう