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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:49:46+00:00 2026-06-01T15:49:46+00:00

I have two tables Table A type_uid, allowed_type_uid 9,1 9,2 9,4 1,1 1,2 24,1

  • 0

I have two tables

Table A
type_uid, allowed_type_uid
9,1
9,2
9,4
1,1
1,2
24,1
25,3

Table B
type_uid
1
2

From table A I need to return

9
1

Using a WHERE IN clause I can return

9
1
24
  • 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-01T15:49:47+00:00Added an answer on June 1, 2026 at 3:49 pm
    SELECT
      TableA.type_uid
    FROM
      TableA
    INNER JOIN
      TableB
        ON TableA.allowed_type_uid = TableB.type_uid
    GROUP BY
      TableA.type_uid
    HAVING
      COUNT(distinct TableB.type_uid) = (SELECT COUNT(distinct type_uid) FROM TableB)
    

    Join the two tables togeter, so that you only have the records matching the types you are interested in.

    Group the result set by TableA.type_uid.

    Check that each group has the same number of allowed_type_uid values as exist in TableB.type_uid.

    distinct is required only if there can be duplicate records in either table. If both tables are know to only have unique values, the distinct can be removed.

    It should also be noted that as TableA grows in size, this type of query will quickly degrade in performance. This is because indexes are not actually much help here.

    It can still be a useful structure, but not one where I’d recommend running the queries in real-time. Rather use it to create another persisted/cached result set, and use this only to refresh those results as/when needed.

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

Sidebar

Related Questions

From the regular aspnet_Users table I have created two sub-tables with one to one
I have two tables (Apple and Bid). I want to return all rows from
I have two tables Table public.tags_to_entities Column | Type | Modifiers --------+---------+----------- tid |
I have two tables: Table 1: ID, PersonCode, Name, Table 2: ID, Table1ID, Location,
I have two tables: a Files table, which includes the file type, and a
I have two tables, Table A with 700,000 entries and Table B with 600,000
I have two tables posts and comments . Table comments have post_id attribute. I
I have two tables with the following schema: CREATE TABLE sales_data ( sales_time date
Can someone please help me with MySQL Trigger Lets say I have two Tables
Suppose I have two tables: Table A has information about the stock holdings of

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.