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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:27:25+00:00 2026-06-12T15:27:25+00:00

Given a join table for m-2-m relationship between booth and user +———–+——————+ | booth_id

  • 0

Given a join table for m-2-m relationship between booth and user

+-----------+------------------+
| booth_id  |          user_id |
+-----------+------------------+
|         1 |                1 |
|         1 |                2 |
|         1 |                5 |
|         1 |                9 |
|         2 |                1 |
|         2 |                2 |
|         2 |                5 |
|         2 |               10 |
|         3 |                1 |
|         3 |                2 |
|         3 |                3 |
|         3 |                4 |
|         3 |                6 |
|         3 |               11 |
+-----------+------------------+

How can I get a distinct set of booth records that are common between a subset of user ids? For example, if I am given user_id values of 1,2,3, I expect the result set to include only booth with id 3 since it is the only common booth in the join table above between all user_id‘s provided.

I’m hoping I’m missing a keyword in MySQL to accompish this. The furthest I’ve come so far is using ... user_id = all (1,2,3) but this is always returning an empty result set (I believe I understand why it is though).

  • 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-12T15:27:26+00:00Added an answer on June 12, 2026 at 3:27 pm

    The SQL query for this will be:

    select booth_id from table1 where [user_id]
    in (1,2,3) group by booth_id having count(booth_id) = 
    (select count(distinct([user_id])) from table1 where [user_id] in (1,2,3))
    

    If this could help you creating the MySQL query.

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

Sidebar

Related Questions

Can you reference the properties of a join table in a has_many :through relationship?
I have a many-to-many relationship between two tables. Table God_Restaurants contains my restaurants. Table
Given a query like: SELECT table1.field1 FirstField, table2.field2 SecondField FROM table1 INNER JOIN table2
Given these two queries: Select t1.id, t2.companyName from table1 t1 INNER JOIN table2 t2
Given an NSArray of NSStrings, is there a quick way to join them together
Given a certain date, I want to set the value of a cell with
Hi i'm struggling to write a particular MySQL Join Query. I have a table
I'm working on a restaurant CMS app. I have a many-to-many relationship between 2
General Case How do you perform a left join across a many-to-many relationship when
I have a table of many-to-many relationships as: Table relationship : relationship_id, first_user REFERENCES

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.