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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. sql statement help

sql statement help

Scheduled Pinned Locked Moved Database
csharpasp-netdatabasehelptutorial
2 Posts 2 Posters 1 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.
  • V Offline
    V Offline
    VinothRao
    wrote on last edited by
    #1

    hi, i have the following table. Parent ID.......ID.......Name NULL..........10001.....Region1 NULL..........10002.....Region2 NULL..........10003.....Region3 10001.........501.......Test1 10001.........502.......Test2 10002.........503.......Test3 10002.........504.......Test4 10003.........505.......Test5 10003.........506.......Test6 501...........507.......Test7 501...........508.......Test8 502...........509.......Test9 502...........510.......Test10 Actually im doing a Treeview control in my ASP.NET application. I can see the Parent Name, and its child popping out, BUT how to see the ID (501, 502) is having child in ParentID?? My SQL in ASP.NET is "SELECT ID, ParentID, Name FROM Test" In order to show Child in the Parent, the ParentID has to be NULL. Any idea??

    R 1 Reply Last reply
    0
    • V VinothRao

      hi, i have the following table. Parent ID.......ID.......Name NULL..........10001.....Region1 NULL..........10002.....Region2 NULL..........10003.....Region3 10001.........501.......Test1 10001.........502.......Test2 10002.........503.......Test3 10002.........504.......Test4 10003.........505.......Test5 10003.........506.......Test6 501...........507.......Test7 501...........508.......Test8 502...........509.......Test9 502...........510.......Test10 Actually im doing a Treeview control in my ASP.NET application. I can see the Parent Name, and its child popping out, BUT how to see the ID (501, 502) is having child in ParentID?? My SQL in ASP.NET is "SELECT ID, ParentID, Name FROM Test" In order to show Child in the Parent, the ParentID has to be NULL. Any idea??

      R Offline
      R Offline
      Robin_Roy
      wrote on last edited by
      #2

      You can get a clue from a simple SQL query like Select distinct ID, ParentID, Name from dbo.tblTest where ID In (Select ParentID from dbo.tblTest) The output would be like ID ParentID Name ----------- ----------- ------------- 501 10001 Test1 502 10001 Test2 10001 NULL Region1 10002 NULL Region2 10003 NULL Region3

      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