Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8058751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:27:05+00:00 2026-06-05T09:27:05+00:00

This is a follow up of the question: SQL Server to show a data

  • 0

This is a follow up of the question: SQL Server to show a data tree in a specific format

Now we have a second table that is related to the first one on the “leaf” rows:

table1:

   Itemid   Itemname    Itemfatherid
    itemA    theitemA    null
    itemB    theitemB    null
    itemC    theitemC    itemA
    itemD    theitemD    itemA
    itemE    theitemE    itemC
    itemF    theitemF    itemE
    itemG    theitemG    itemD

In this table itemF and itemG would be leafs (they dont have any children)

table2:

   Itemid   RelItemid
    item1    itemF
    item2    itemF
    item3    itemG

The visual relation would be like this:

-itemA
    -itemC
        -itemE
            itemF (item1, item2)
    -itemD
        itemG (item3)
itemB

And we need to get all the rows from the 2nd table that are related to the first table filtering it by an especified node.

Examples:

Filtering by node itemA: item1, item2, item3
Filtering by node itemE: item1, item2
Filtering by node itemD: item3
Filtering by node itemG: item3
Filtering by node itemB: 

Sorry for the long post, its in order to cover any holes…thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T09:27:06+00:00Added an answer on June 5, 2026 at 9:27 am

    In the end we solved it looping throu the results and doing sqls to get related rows from the second table…not the desired solution but the one feasible

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is a follow-up question of mine. Suppose now I have a URL :
I have a SQL Server 2005 database that stores data for multiple users. Each
Follow up to this question This (similar version from old link) works in SQL
This is a follow up question to T-Sql xml query If I add a
I have upgraded from SQL Server 2005 to 2008. I remember that in 2005,
I'm working on an online muiltiplayer board game & have a SQL server question.
I have a simple database table (SQL Server 2008 R2 Express), which has a
This question is a follow up to an earlier question I had that was
This is a follow up question to a previous question I asked about calculating
This is a follow-on question from the one I asked here . Can constraints

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.