I have a table with following format
TaskID ParentTaskID
1 1
2 1
3 2
4 2
5 2
10 10
11 11
12 11
13 0
14 14
I want the result as below,if taskid is 1
TaskID
1
2
3
4
5
if its 2 then
Taskid
2
3
4
5
if its 10 then 10
means I want to select rows having taskid =1 with rows having parenttaskid=1 with rows having parenttaskid in above selection & so on........
please use this fiddle http://sqlfiddle.com/#!2/9db0c3/6