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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:23:42+00:00 2026-05-25T23:23:42+00:00

I am a new and am having some trouble with joining two tables. table1:

  • 0

I am a new and am having some trouble with joining two tables.
table1: (topicID, questionID) where topicID is the primary key. For each topicID, there are many questionID’s.

Now, I have a table2 with questioIDs and I want to get all those topicID’s from table1 which have atleast one entry for each questionID in table2.

I would appreciate any help.

create table table1(
    topicID int,
    questionid int)
create table table2
(
    questionid int
)
insert into table1
select 1,1
union all
select 2,1
union all
select 2,2
union all
select 2,4
union all
select 1,2
union all
select 1,6

insert into table2 
select 1
union all
select 2
union all
select 6

Using table1 and table2 above, the query should return topicID as 2 as only this has atleast one entry for each questionID’s in table2.

Thanks

  • 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-25T23:23:42+00:00Added an answer on May 25, 2026 at 11:23 pm

    The relational operator you require is division, popularly known as “the supplier who supplies all parts”.

    Because your spec states “has at least one entry for each questionID”, I think you should be looking at division with remainder.

    p.s. this is not a topic you’ll find “on Page 1 of almost any SQL reference”, rather it is one of the more obscure relational operators!

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

Sidebar

Related Questions

I'm new to linq and having trouble writing two simple queries. For some reason,
I'm completely new to Visual Studio and I'm having some trouble getting a project
Still new to Objective C, and I'm having some trouble that I just can't
I'm new to Ruby, so I'm having some trouble understanding this weird exception problem
I'm very new to JQuery, and I'm having some trouble understanding how to do
I'm having some trouble with switching to the new JS API for a number
I'm having some trouble nutting out why I'm unable to connect to a new
I'm having some trouble with a word add-in. I'm attempting to create a new
I am new to hibernate and I am having some trouble with the named
I am fairly new to xslt (2.0) and am having some trouble with a

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.