现在有一表roleTab
id farthId
0 NULL
1 0
2 1
3 2如何用一条语句查询出来这样的结果:
0、查询0的farthId结果为
NULL1、查询1的farthId结果为
farthId
02、查询2的farthId结果为
farthId
0
13、查询3的farthId结果为
farthId
1
2
id farthId
0 NULL
1 0
2 1
3 2如何用一条语句查询出来这样的结果:
0、查询0的farthId结果为
NULL1、查询1的farthId结果为
farthId
02、查询2的farthId结果为
farthId
0
13、查询3的farthId结果为
farthId
1
2
select distinct a.id from roletab as a inner join roletab as b on (a.fatherid= b.fatherid) where b.fatherid>=?