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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:03:03+00:00 2026-06-07T12:03:03+00:00

Given two tables (the rows in each table are distinct): 1) x | y

  • 0

Given two tables (the rows in each table are distinct):

 1)  x | y     z   2)  x | y     z
    -------   ---     -------   ---
     1 | a     a       1 | a     a
     1 | b     b       1 | b     b
     2 | a             1 | c
     2 | b             2 | a
     2 | c             2 | b
                       2 | c

Is there a way to select the values in the x column of the first table for which the subset of values in the y column, for that x, matches exactly the values in the z column of the second table?

In case 1), expected result is 1. If c is added to the second table then the expected result is 2.
In case 2), expected result is no record since neither of the subsets in the first table matches the subset in the second table. If c is added to the second table then the expected result is 1, 2.

I’ve tried using except and intersect to compare subsets of first table with the second table, which works fine, but it takes too long on the intersect part and I can’t figure out why (the first table has about 10.000 records and the second has around 10).

EDIT: I’ve updated the question to provide an extra scenario.

  • 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-06-07T12:03:05+00:00Added an answer on June 7, 2026 at 12:03 pm
    SELECT
      table1.x
    FROM
      table1
    INNER JOIN
      table2
        ON table1.y = table2.z
    GROUP BY
      table1.x
    HAVING
          COUNT(*) = (SELECT COUNT(*) FROM table2 AS lookup)
      AND COUNT(*) = (SELECT COUNT(*) FROM table1 AS lookup WHERE x = table1.x)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which has two fields. There can be multiple rows with
given the two tables and values: Tables People- Columns: [ID]PK Name Field - Columns:
Problem Given the following two tables, I'd like to select all Ids for Posts
I have two table masterTbl and detailTbl which structure is given below... --PRIMARY TABLE
I have a table which represents a Contract between two rows in another table.
I have two tables. Widgets, which has information about each widget (Color, size, etc);
I have two tables, each with three boolean (ms-access Yes/No) columns. Table 1: A1,
I have two tables. One is a 'Users' table. Each row (user) in the
I have two table functions that return a single column each. One function is
Given two tables APPLE and ORANGE, NAME APPLES Alice 5 Bob 10 Trudy 1

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.