I have some objects which are linked via a link table, which has Parent/Child columns.
Here is the scenario. The ones above are parents, the ones below are children.
The table linking these like this is thus:
P C
1 2
1 3
1 4
1 5
1 6
2 7
2 8
2 9
7 10
7 11
10 12
10 13
4 12
6 13
Where P=Parent, C=Child.
I want to devise a query where if I pick a Child (say 13) I get the rows back which are affected by said child.
As in the ones asterisked:
P C
1 2 *
1 3
1 4
1 5
1 6
2 7 *
2 8
2 9
7 10 *
7 11
10 12
10 13 *
4 12
6 13 *
The DB is SQLserver.
1 comment:
Which version of SQL server ?
No access to test just now, but sounds like you need help from analytic functions. http://technet.microsoft.com/en-us/library/hh231256.aspx
Post a Comment