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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:24:36+00:00 2026-05-16T12:24:36+00:00

Say I have four tables: ————- features ————– id: int name: varchar ————————————- ——–

  • 0

Say I have four tables:

------------- features --------------
id: int
name: varchar
-------------------------------------

-------- feature_categories ---------
feature_id: int
category_id: int    
-------------------------------------

----------- categories --------------
id: int
name: varchar    
-------------------------------------

------ category_subcategories -------
category_id: int
sub_category_id: int    
-------------------------------------

category has many (sub)categories, through self referential join subcategories

A feature has many categories, of those some will be subcategories, through join feature_categories

What I need is to send an array of feature ids and a (main) category id and have returned all subcategories. This is proving more difficult than I would have hoped so I’d appreciate greatly any help. Let me know if this question isn’t clear.

EDIT
I don’t need the feature table to be included in any query. In facet, I only require the subcategory (category) name field to be returned.

  • 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-16T12:24:37+00:00Added an answer on May 16, 2026 at 12:24 pm

    Had to work through this a bit, but either below should work. 2nd one is probably more efficient:

     select f.name featureName, 
      c.name CategoryName, 
      c2.name SubCategoryName  
        FROM features f, feature_categories fc, categories c, category_subcategories sc, categories c2, feature_categories fc2
        WHERE f.id = fc.feature_id
        AND c.id = fc.category_id
        AND sc.category_id = c.id
        and c2.id = sc.sub_category_id
        and fc2.category_id = c2.id
        AND f.id in (0,1,2,...)
        and fc2.feature_id in (0,1,2,...)
        AND c.id = @main_category_id
    

    or:

        select f.name featureName, 
      c.name CategoryName, 
      c2.name SubCategoryName  
            FROM features f 
            inner join feature_categories fc on f.id = fc.feature_id
            inner join categories c on c.id = fc.category_id
            inner join category_subcategories sc on sc.category_id = c.id
            inner join categories c2 on c2.id = sc.sub_category_id
            inner join feature_categories fc2 on fc.category_id = c2.id
    
            WHERE f.id in (0,1,2,...)
            AND c.id = @main_category_id
    
            and fc2.feature_id in (0,1,2,...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say i have Four tables 1) Studnets: Student_ID First Name Last Name 2) Contact
Say I have four tables, users , contacts , files , and userfiles .
I have a table with four columns, say P_Key(int), Ref_Key(int), Key(String), Value(Integer). I want
Let's say I have four tables: PAGE , USER , TAG , and PAGE-TAG
We have situation where say we have four engineers that are working on software
Let's say I have the following xml: <one> <two> <three> <three> foo </three> <four
Lets say have this immutable record type: public class Record { public Record(int x,
Say I have three tables, a table of users, a table of around 500
Let me explain my problem: I have four tables created as objects using Entity
Let's say I have rows of data retrieved from a relational database tables (perhaps

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.