我想insert from Table1 the rows are not in Table2.
SQL:INSERT INTO忽略是否存在
的事情是錯誤的有節點與parentId = 0
在表2。
所以我需要從所有父母的所有兒子都在表2和insert
他們,如果他們不是在Table2與父母曾用於表2上的密鑰。
我爲每個表有兩個鍵,而不只是一個。有我的問題。
如果有人可以給我手,我可以使用cursors
。
Table1
IDNode, IDParent
1 0
2 1
3 1
4 1
5 0
6 5
Table2
IDNode, IDKey
1 1
1 7
2 6
4 2
5 3
IdNode IDparent IDkey
2 1 1
3 1 1
4 1 1
2 1 7
3 1 7
4 1 7
remove the IDNode2 with IDKey6
remove the IDNode4 with IDKey2
6 5 4
父親更重要的是,如果在我的表2我有一個關鍵的父母,我需要找到形式table1的兒子,與父親的鑰匙插入其中的關鍵,如果存在與兒子不同的鍵刪除它,畢竟刪除表2中的父節點
hi..i覺得對於表2,你是顯示這裏是confusing..please說清楚的結果.. – user1102001
「插入他們,如果他們不在表2與父母曾用於表2的密鑰「 - 不是最清楚的描述 - 但這解釋了它。 –
我認爲4的樣本結果不正確,但 - 不應該是1? –