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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:56:43+00:00 2026-05-30T23:56:43+00:00

I have some tables like this : I. parent table : id_client id_group package

  • 0

I have some tables like this :

I. parent table :

id_client      id_group   package       start_date   end_date     id_contract   is_parent   
1223           88         1234          2012-01-01   2050-01-01   156447        1           
1223           89         34342         2011-04-01   2050-01-01   156447        1 

II. share table :

id        package      id_share
1         1234         SS4433  - parent
2         564679       SS4433  --- this is a child
3         564522       SS4433  -- this is a child 
4         34342        SS2345  - parent
5         665456       SS2345  -- child
6         7789997      SS2345  -- child

III. child table :

package       start_date   end_date      id_contract      

564679        2011-01-01   2012-02-01    156447
564522        2011-01-01   2011-05-07    156447
665456        2011-01-01   2012-02-04    156447
7789997       2011-01-01   2011-07-03    156447

The question is how to select with one query the parent and all it’s children in the same select (based on id_share in share table), that contains the group of the parent.

The result should look like this:

id_client      id_group      package         start_date  end_date    id_contract   child_of
1223           88            1234            2012-01-01  2050-..     156447        0
1223           88            564679          2011-01-01  2012-02-01  156447        1234
1223           89            34342           2011-04-01  2050-...    156447        0
1223           89            665456          2011-01-01  2012-02-04   156447        34342

I have tried in every way .. but I can’t figure it out how to do it .. without union all

I have tried this :

select a.id_client, a.id_group, ??package?? , id_contract , ??child_of??
from parent_table a 
join share_table b on b.package = a.package
join share_table c on c.id_share = b.id_share
join child_table d on d.package = c.package

PS: I need to find parents and childs that corespond to 2012-01-01 – 2012-01-31 interval

where i have put ?? i don;t know .

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-05-30T23:56:44+00:00Added an answer on May 30, 2026 at 11:56 pm

    UPDATED, to restrict parents and children by date:

    select a.id_client,
           a.id_group,
           coalesce(d.package, a.package) package,
           coalesce(d.start_date, a.start_date) start_date,
           coalesce(d.end_date, a.end_date) end_date,
           coalesce(d.id_contract, a.id_contract)  id_contract,
           case when d.package is not null then a.package else 0 end child_of
    from parent_table a 
    join share_table b on b.package = a.package
    join share_table c on c.id_share = b.id_share
    left join child_table d on d.package = c.package and
                               d.start_date <= '2012-01-31' and
                               d.end_date >= '2012-01-01' 
    where a.start_date <= '2012-01-31' and
          a.end_date >= '2012-01-01' and
          (d.package is not null or a.package = c.package)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some legacy layouts with nested tables. I'd like the parent table's <td>
I currently have a table structure that looks something like this(some details omitted): ColumnName
I have some Oracle tables that represent a parent-child relationship. They look something like
I have two already-existing tables which look (in part) roughly like this: CREATE TABLE
I have a Linux web server and I'd like to make some database tables
I have some code to update a database table that looks like try {
I have an Excel table with some data that I would like to export
I have a table that saves some account limits like users. For most rows
I have some tables that benefit from many-to-many tables. For example the team table.
I have a simple table like this <table id=tempTable> <tbody> <tr id=row_01> <td> <button

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.