SQL query statement-type of the returned name

Source: Internet
Author: User
 1:   
 2:   
 3:   
4: --- already? Zhi? Abnormal? Name? ? Parent_id query? Inquiry? Which? Points? Class?
 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: --- already? Zhi? Connected? Affected? Name? ? Id ,? Check? Inquiry? Which? Points? Class?
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:   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.