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. This query is making me crazy... [modified]

This query is making me crazy... [modified]

Scheduled Pinned Locked Moved Database
databasehelp
3 Posts 2 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.
  • _ Offline
    _ Offline
    _Zorro_
    wrote on last edited by
    #1

    Hi, I have to show a filesystem on a page. The information is stored in a table where I have ID(PK), Name, Parent, Order 001, Node1, NULL, 1 002, Node2, NULL, 2 003, Node3, 001, 1 004, Node4, 001, 2 005, Node5, 002, 2 I need to display the results as it should be seen: +Node1 Node3 Node4 +Node2 Node5 The query I have is like this: SELECT A.* FROM TableFS A LEFT OUTER JOIN TableFS B ON A.ParentID = B.ItemID ORDER BY A.ParentID, B.Order The result is similar to what I should get, but similar is not enough... at least it's what they tell me... ;P If anyone can help... :rolleyes: Thanks...!

    K 1 Reply Last reply
    0
    • _ _Zorro_

      Hi, I have to show a filesystem on a page. The information is stored in a table where I have ID(PK), Name, Parent, Order 001, Node1, NULL, 1 002, Node2, NULL, 2 003, Node3, 001, 1 004, Node4, 001, 2 005, Node5, 002, 2 I need to display the results as it should be seen: +Node1 Node3 Node4 +Node2 Node5 The query I have is like this: SELECT A.* FROM TableFS A LEFT OUTER JOIN TableFS B ON A.ParentID = B.ItemID ORDER BY A.ParentID, B.Order The result is similar to what I should get, but similar is not enough... at least it's what they tell me... ;P If anyone can help... :rolleyes: Thanks...!

      K Offline
      K Offline
      Krish KP
      wrote on last edited by
      #2

      SELECT A.* FROM TableFS A INNER JOIN TableFS B ON A.ItemID = B.ParentID ORDER BY A.ParentID, B.Order

      Regards KP

      _ 1 Reply Last reply
      0
      • K Krish KP

        SELECT A.* FROM TableFS A INNER JOIN TableFS B ON A.ItemID = B.ParentID ORDER BY A.ParentID, B.Order

        Regards KP

        _ Offline
        _ Offline
        _Zorro_
        wrote on last edited by
        #3

        Sorry, but this is not even close. Items without parents have value in NULL, so your querry dosen't take those nodes in charge, and gives me duplicated values anyway. Thanks for your time :)

        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