title: How to select a subset using MySQL
body: <p>​
  In general, I'm trying to learn the best MySQL practice for selecting a set of records in one table whose fields are a subset of records from another table. Specifically...</p>
  
  <p>​The team_competition table stores the competitions a team is registered for:</p>
  
  <p>Team    Competition</p>
  
  <p>630     AGLOA2017ELCE</p>
  
  <p>630     AGLOA2017ELEQ</p>
  
  <p>630     AGLOA2017ELPREZ</p>
  
  <p>630     AGLOA2017ELPROP​</p>
  
  <p>...</p>
  
  <p>The player_competition table stores the competitions a player is registered for:</p>
  
  <p>Player  Competition</p>
  
  <p>186     AGLOA2017SREQ</p>
  
  <p>186     AGLOA2017SRLING</p>
  
  <p>186     AGLOA2017SROS</p>
  
  <p>186     AGLOA2017SRPREZ</p>
  
  <p>186     AGLOA2017SRPROP</p>
  
  <p>186     AGLOA2017SRWFF</p>
  
  <p>191     AGLOA2017SREQ</p>
  
  <p>191     AGLOA2017SRLING</p>
  
  <p>191     AGLOA2017SROS</p>
  
  <p>191     AGLOA2017SRPREZ</p>
  
  <p>191     AGLOA2017SRPROP</p>
  
  <p>191     AGLOA2017SRWFF</p>
  
  <p>...</p>
  
  <p>To assign players to teams, I need to select players who are registered for the same competitions as the team in question. For team 630 in this example, I need to select players who are registered for <em>at least</em> those four competitions: AGLOA2017ELCE, AGLOA2017ELEQ, AGLOA2017ELPREZ, and AGLOA2017ELPROP​.</p>
  
  <p>Mathematically, I think this is equivalent to selecting players' competitions that are a superset (contain) of the team's competitions. I'm currently using a moderately complicated routine to loop through players and competitions and compare each one to the team's competitions. It works, but seems grossly inefficient.</p>
  
  <p>I'm studying how to use MySQL to select 'subsets,' but I've hit a mental block. When that happens, I can usually make some progress by writing down my question. Just typing this has given me some ideas, but now that it's written...</p>
  
  <p>... thanks in advance for sharing any solutions you may have.</p>