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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:25:40+00:00 2026-05-24T21:25:40+00:00

I have an n:n set of data (for example, ‘programmers’ and ‘languages’. Programmers write

  • 0

I have an n:n set of data (for example, ‘programmers’ and ‘languages’. Programmers write code in many languages, and a language can be used by many programmers). This data is in a table programmers_languages

How do I quickly select programmers who code in all of a set of languages?

More information if this is confusing:

Jon codes in C++, Pascal, and Ruby. Joe codes in C++ and Ruby. Moe codes in Ruby and Pascal. Steve Codes in C++ and Pascal.

If the set of languages in question is C++ and Pascal, I would want Jon and Steve from this list.

Note the size of this set can get pretty large, so I don’t want to join the table to itself n times.

  • 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-24T21:25:40+00:00Added an answer on May 24, 2026 at 9:25 pm

    Note the size of this set can get pretty large, so I don’t want to join the table to itself n times.

    Any way you shake it, there’s going to be a join for each language. You’re looking for a value (programmer) for which there exists at least one row for each of another value (language). That means that you need to think about N different perspectives of the same table.

    In most cases, it’s probably most efficient for you to just do the joins. If the result set is sufficiently dense (really, most programmers speak python and c++), you could resort to some cleverness. First query the disjunction, but uniquely, then group the resulting relation by programmer and filter out the ones that speak too few languages…

    SELECT programmer
    FROM ( SELECT DISTINCT programmer, language
           FROM speaks_table
           WHERE language in ('C++', 'python') ) AS disjunction
    GROUP BY disjunction.programmer
    HAVING count(disjunction.language) = 2
    

    But wether this outperforms a regular ol’ multiway join is going to depend on the exact data in question. This at least has the advantage of not requiring generative queries depending on the number of languages in question.

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

Sidebar

Related Questions

So I have a set of data that can look like this (sample line-by-line):
I have a set of custom data types that can be used to manipulate
We have this set of data that we need to get the average of
I have a set of data, with columns x and y. This set contains
I have a set of data that is structured like this: ItemA.GroupA ItemB.GroupA ItemC.GroupB
I have two data tables in a data set for example lets say Servers:
Here is the example data set i have : id | messageread | timestamp
I have a set of data that models a hierarchy of categories. A root
I have a set of data protected by 16bit checksums that I need to
I have a set of data that needs to be displayed as a crosstab

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.