I have a table Category with Parent and Child relations my table schema is below:
CategoryID ParentID CategoryName
1 0 A
2 1 B
3 1 C
4 2 D
5 0 E
6 5 F
7 5 G
8 6 I
9 1 J
10 0 L
Now When I want to select all categories which did not have the ParentId 1 and it’s Child CategoryID, my output should be look like below when I am passing CategoryID 1
CategoryID ParentID CategoryName
5 0 E
6 5 F
7 5 G
8 6 H
10 0 L
how I can find the results look like that.
The gist of this is to
SQL Statement
Test data