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

  • Home
  • SEARCH
  • 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 8250175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:47:51+00:00 2026-06-07T23:47:51+00:00

I am having problem in framing one sql query. I need to select all

  • 0

I am having problem in framing one sql query.
I need to select all records based on Transaction ID as I explained below

  1. Assume user given transaction TX444, I need to fetch all records with Child Id = Parent Id of given transaction AND Parent_Id = Child_Id of already selected records.

So if I give TRansaction as TX444, all records shown should be selected.

  1. Assume user given Transaction = TX234, then I need to fetch all records with Child Id = Parent Id of given transaction AND Parent_Id = Child_Id of already selected records.
    in this case last record will not be included.

I am trying to write SELECT query. But nothing is working 🙁

PARENT_ID       CHILD_ID                   TRANSACTION        STATE
1               4                           TX123           PF
2               4                           TX128           PS
3               5                           TX230           FF
4               5                           TX234           FS
5               0                           TX444           DS

I am not SQL person, but I need to make this up

  • 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-07T23:47:52+00:00Added an answer on June 7, 2026 at 11:47 pm

    In Oracle you can use CONNECT BY to recursively loop through rows:

    SELECT  Parent_ID, 
            Child_ID, 
            Transaction, 
            State,
            CASE Level WHEN 1 THEN 'Selected' ELSE 'Child' END AS Relation
    FROM    Transactions
    START WITH Transaction = 'TX444'
    CONNECT BY PRIOR Child_ID = Parent_ID
    UNION
    SELECT  Parent_ID, 
            Child_ID, 
            Transaction, 
            State,
            CASE Level WHEN 1 THEN 'Selected' ELSE 'Parent' END AS Relation
    FROM    Transactions
    START WITH Transaction = 'TX444'
    CONNECT BY PRIOR Parent_ID = Child_ID;
    

    I’ve put an example on SQL Fiddle, but I’ve used slightly different children/parents to your data to fully show how you can use CONNECT BY not just to get the parents/children, but also to determine what generation each is.

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

Sidebar

Related Questions

I am having problem with named query parameter. My query is as follow: <sql-query
I'am having problem in accessing json array elements. Below is the response when i
i'm having problem when i want to select element using querySelector <ul class=xoxo blogroll>
i having problem with draw image in applet. i want to display all images
Having problem in displaying relational properties b/w two tables having one(company) to many(package_master) relationship
am having problem, my app doesn't seem to check the radio button based from
I am having problem getting my query to exclude my soft delete column I
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
Im having problem in my UIscrollView ,this is what I have done: Whenever a
I am having problem using mvc:resources in spring 3.1 configuration. Initially i was working

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.