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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:45:16+00:00 2026-05-13T20:45:16+00:00

I am trying to create a query which will return all rows of a

  • 0

I am trying to create a query which will return all rows of a table CLASSES that do not matched with another table named CHILD_CLASSES. These two tables look like this,

The table CLASSES is a self referencing table so the top CLASS does not have a parent_id. The Parent ID row is created from the class_id row. So when I inserted A1 as a sub class to A then its parent ID is 1 because A’s class_id is 1. And then A11 is a sub class to A1 as well as A12 so their parent_ids will be 2.

CLASS_ID  |  PARENT_ID | CLASS_NAME
-----------------------------------
  1       |     --     |    A
  2       |     1      |    A1
  3       |     2      |    A11
  4       |     2      |    A12

I then have another table CHILD_CLASSES which will store the children of each CLASS. Since A is the top Class it will have the children of everything below it, A1, A11, and A12. A1 will only have A11 and A12. It looks like this

ID   | PARENT_ID | CLASS_ID
----------------------------
  1  |     1     |    2
  2  |     1     |    3
  3  |     1     |    4
  5  |     2     |    3
  6  |     2     |    4

This is a little archaic but all I am really looking for is a query that will return to me the rows in the CLASSES table that do not have children for a given CLASS_ID. For example, if I run the query on A1 which is class_id 2, it will return to me rows with the class_ids of 1 because the CLASS A is CLASS that has not been set as a child of A1 in the CHILD_CLASSES table. If I were to run the query on A11 then I would get class_ids 1, 2, and 4 because A1 has no children yet, and so on. Any help would be much appreciated.

  • 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-13T20:45:16+00:00Added an answer on May 13, 2026 at 8:45 pm
    SELECT  *
    FROM    classes c
    WHERE   class_id NOT IN
            (
            SELECT  class_id
            FROM    child_classes cc
            WHERE   cc.parent_id = 2
            )
            AND class_id <> 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a report in SSRS2000 that will query an ORACLE
I have 4 databases with similar schema's, and I'm trying to create a query
I'm trying to create a linq query based on some dynamic/optional arguments passed into
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create my first iPhone app that would play back audio. When I
Trying to create a small monitor application that displays current internet usage as percentage
Trying to create a list to return some JSON data to a view. Following
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
Trying to create a user account in a test. But getting a Object reference
Trying to create several layers of folders at once C:\pie\applepie\recipies\ without using several different

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.