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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:28:53+00:00 2026-05-23T14:28:53+00:00

table_a : id label —————– 1 l1 2 l2 3 l3 table_b : table_a_id

  • 0

table_a:

id        label
-----------------
1         l1
2         l2
3         l3

table_b:

table_a_id      table_c_id
---------------------------
1               1
1               3
1               4
2               2
2               4
3               1
3               4
3               8

How can I select all records from table_a that are associated with both table_c_id 1 AND 4? Is it possible to have n table_c_id conditions?

The following is wrong, but it illustrates what is needed.

SELECT table_a.* 
 FROM table_a
 JOIN table_b ON ( table_a_id = id 
               AND table_c_id = 1
               AND table_c_id = 4 )
  • 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-23T14:28:54+00:00Added an answer on May 23, 2026 at 2:28 pm

    Use an IN clause.

    EDIT: Updated the query based on the comments posted.

    SELECT a.* 
          FROM table_a a INNER JOIN
                (
                SELECT table_a_id
                   FROM table_b
                WHERE table_c_id IN(1,4)
                    GROUP BY  table_a_id 
                   HAVING COUNT(DISTINCT table_c_id) > 1
                    --HAVING COUNT(1) > 1 --This scenario will not address repeating table_c_id's
            ) b 
    ON a.id = b.table_a_id          
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to select a grouped average. a1_avg = session.query(func.avg(Table_A.a1_value).label('a1_avg'))\ .filter(between(Table_A.a1_date, '2011-10-01', '2011-10-30'))\
TABLE_A Rev ChangedBy ----------------------------- 1 A 2 B 3 C TABLE_B Rev Words ID
I'm using XSL-FO to create PDF's. Now I have a label that I want
I want to show a label rotated 90 degrees (so I can put a
I am trying to use a label from another row in the gridview and
I am trying to search a table looking for all the labels in that
Using odbc how do I select something from a table and output to a
How can I get the width of a label after set its contents? No
I have a table layout panel that in each row i have a Label
I know that you can use keywords with labels, but is there any way

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.