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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:30:50+00:00 2026-06-17T15:30:50+00:00

I have data in below structure. A A1 A2 B B1 C C1 C2

  • 0

I have data in below structure.

A
    A1 A2

    B  B1

    C  C1 C2 C3

These information transferred into two table named group1 and group2.

group1 has first level of data and middle level data.

group2 has last level of data and middle level data.

ie

group1

 group_name    group_id
  A             1
  A1            2
  B             3
  C             4
  C1            5
  C2            6

group2

 group2_name   parent_id
   A1             1
   A2             2
   B              1  
   B1             3
   C              1
   C1             4
   C2             5
   C3             6

Now i want to get the last level of information under the group A.

My output could be

group2_name
A2
B1
C3

I can fetch the information level 2 by using below query.

select group2.group_name from group2 
inner join
group1 on group1.group_id = group2.parent_id
where group1.group_name = 'A'

How can get the above output?

Here is SQLFIDDLE Demo

Kindly help me.

  • 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-17T15:30:51+00:00Added an answer on June 17, 2026 at 3:30 pm

    You could use this:

    select
      group2.group_name
    from
      group2 left join group1
      using(group_name)
    where
      group1.group_name is null
      and group2.group_name like 'A%'    
    

    that returns all elements from table group2 that are not present in table group1.
    Or (depending on how your database is structured) also this:

    select
      concat(left(group_name,1),
        case when max(mid(group_name,2,length(group_name)-1)+0)>0 then
                  max(mid(group_name,2,length(group_name)-1)+0)
             else '' end)
    from group2
    where group2.group_name like 'A%'
    group by left(group_name,1)
    

    here I am grouping for the first character of the string, and getting the maximum value of the numeric value.

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

Sidebar

Related Questions

I have a table that has data like below(sorted by date) COL_A | COL_B
Question 1: I have a table with the below structure and data: app_id transaction_id
I have a data structure which is as given below: class File { public
I do have a table data as shown below: <td> <label for=title>Title : </label>
I have a table that contains some data given below. It uses a tree
I have a data structure of the form below (V is Data.Storable.Vector): data Elems
i have data below from streaming: 'ID|20120206|080500|0000001|0|1|record1|END' 'ID|20120206|080500|0000002|0|1|record2|END' 'ID|20120206|080500|0000003|0|1|record3|END' and i want to process
I have data like below AAAAAA BBBBBB CCCCCC DDDDDD EEEEEE Now there is a
I have the data below saved as a pandas dataframe . With this data,
I have data stored as below in an MS Access database: Date User 20090101

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.