Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. query to get number of childs from parent child table

query to get number of childs from parent child table

Scheduled Pinned Locked Moved Database
questiondatabase
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sepel
    wrote on last edited by
    #1

    hi i have a table that store my subject. each subjct has a parentid that refer to one subject id in itself table. how can i write query that return subject with number of there childs?

    sepel

    B R P 3 Replies Last reply
    0
    • S sepel

      hi i have a table that store my subject. each subjct has a parentid that refer to one subject id in itself table. how can i write query that return subject with number of there childs?

      sepel

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      Where are stored childs of subject? In which table?


      I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

      1 Reply Last reply
      0
      • S sepel

        hi i have a table that store my subject. each subjct has a parentid that refer to one subject id in itself table. how can i write query that return subject with number of there childs?

        sepel

        R Offline
        R Offline
        razov
        wrote on last edited by
        #3

        can you give structure of tables you are talking about and structure of output you need?

        1 Reply Last reply
        0
        • S sepel

          hi i have a table that store my subject. each subjct has a parentid that refer to one subject id in itself table. how can i write query that return subject with number of there childs?

          sepel

          P Offline
          P Offline
          Paddy Boyd
          wrote on last edited by
          #4

          You might want to have a google and look at recursive common table expressions (CTE) (if you're on SQL2005).

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups