1:
2:
3:
4: ---已?知?异?名?的?parent_id查?询?其?分?类?
5: SELECT id ,
6: name_string ,
7: parent_id ,
8: name_state ,
9: published_year ,
10: ( SELECT COUNT(*)
11: FROM dbo.names
12: WHERE parent_id = n.id
13: ) AS childnodecount
14: FROM dbo.names AS n
15: WHERE n.parent_id = 37388
16: UNION
17: ( SELECT id ,
18: name_string ,
19: parent_id ,
20: name_state ,
21: published_year ,
22: ( SELECT COUNT(*)
23: FROM dbo.names
24: )
25: FROM dbo.names
26: WHERE id = 37388
27: )
28: ORDER BY name_state ,
29: published_year
30:
31:
32: ---已?知?接?受?名?的?id,?查?询?其?分?类?
33: SELECT id ,
34: parent_id ,
35: name_string ,
36: name_state ,
37: published_year
38: FROM dbo.names
39: WHERE id = 37388
40: UNION
41: ( SELECT id ,
42: parent_id ,
43: name_string ,
44: name_state ,
45: published_year
46: FROM dbo.names
47: WHERE parent_id = 37388
48: )
49: ORDER BY name_state ,
50: published_year
51:
52:
53: