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 7738917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:23:26+00:00 2026-06-01T08:23:26+00:00

I have a table that shows the relationships between people a bit like this.

  • 0

I have a table that shows the relationships between people a bit like this.

id  linked_id
1   2
1   3
3   4
4   1

There is no apparent order to the table or the relationships.

I’m trying to find a way to list all the ids that have any kind of link to a given id. So for examples from the table above:

id = 1 would return 1, 2, 3 and 4.
id = 2 would also return 1, 2, 3 and 4

It’s an oracle database, and the query would have to be in plain SQL. Thanks for your help, this has been driving me nuts.

  • 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-01T08:23:28+00:00Added an answer on June 1, 2026 at 8:23 am

    You could use something like this:

    SELECT linked_id
      FROM DATA
     START WITH ID = :1
    CONNECT BY NOCYCLE PRIOR ID = linked_id
            OR ID = PRIOR linked_id
    UNION
    SELECT ID
      FROM DATA
     START WITH linked_id = :1
    CONNECT BY NOCYCLE PRIOR ID = linked_id
            OR ID = PRIOR linked_id
    UNION
    SELECT :1 FROM dual
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data.frame and I'm trying to create a frequency table that shows
I have the following table, Persons_Companies , that shows a relation between persons and
I have to build an HTML table that shows data for users versus pages
I have a following table using MVC that shows number of items the user
I have an application that shows data from a MySQL table. Basically, my application
I would like to have a table header that looks like the image shown
Basically what I'm trying to do, there are users that have applicable services within
I'm dealing with a large multi-national corp. I have a table (oldtir) that shows
I have the classical table with expandable and collapsible records that if expanded show
I have table that I insert data with following query (from c# code): INSERT

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.