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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:53:26+00:00 2026-05-13T15:53:26+00:00

I have a complex query that includes some dynamic sql which partially depends upon

  • 0

I have a complex query that includes some dynamic sql which partially depends upon a checkboxlist. Here’s the part that has me stumped right now (brain fart?).

Simple example:

Table A (id, name)

Table B (id, Aid, Cid)

Table C (id, color)

So lets say Table A has:

1, Bob
2, Tim
3, Pete

and Table C has:

1, Red
2, Blue
3, Green

Now Table B has

1, 1, 1
2, 1, 2
3, 3, 2

So that Bob’s favorite colors are Red and Blue and Pete’s favorite colors are only Blue.

How do I query so that I only retrieve rows from Table A that have favorite colors of both Red and Blue. I don’t want to see Pete in my resultset.

  • 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-13T15:53:26+00:00Added an answer on May 13, 2026 at 3:53 pm

    You want to use the INTERSECT operator to get those that match both, this is SQL 2005+ only, however.

    SELECT name FROM TableA
    WHERE ID IN (SELECT Aid FROM TableB WHERE CId = 1
                 INTERSECT
                 SELECT Aid FROM TableB WHERE CId = 2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 317k
  • Answers 317k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Check if you did not attach the handler function twice… May 13, 2026 at 11:38 pm
  • Editorial Team
    Editorial Team added an answer You are not doing something wrong. MSDN is wrong. Application.LoadComponent… May 13, 2026 at 11:38 pm
  • Editorial Team
    Editorial Team added an answer Basically you have to do the following: $form->setDefault('field_name', array('from' =>… May 13, 2026 at 11:38 pm

Related Questions

I've alluded to this project before, in this question, but the scope of redesign
I need to make a rather complex query, and I need help bad. Below
I currently have multiple queries that query data from a few tables linked through
Say I have default content on the left side of my application, which is
I've been having a look at several MVC frameworks (like rails, merb, cakephp, codeignitier,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.