title: Compare all records of a n-n relationship
body: <p>I have three tables, A,B and C</p>
  
  <p>Tables A and B have an ID and other fields, table C is a n-n relationship of A and B (C contains only IDS of A and B with primary key(id_a, id_b) and foreign key).</p>
  
  <p>Now I need to verify if a row of A has the same associations of another row of A.</p>
  
  <p>EXAMPLE</p>
  
  <pre><code>A = [id_a] = [1,2,3,4]
  B = [id_b] = [1,2,3,4]
  
  C = [id_a, id_b] = [[1,1],[1,3],[2,1],[2,3],[3,3]]
  </code></pre>
  
  <p>In this case, I need to extract only records where id_a are 1 and 2, because they are both associated with the same row of B (id_b 1 and 3).</p>
  
  <p>id_a=3 is not the same as id_a=1/2, because it isn’t associated with id_b=1</p>
  
  <p>This is for a new Ubuntu 18.04 server, running MySQL, PHP 7 (LAMP stack)</p>
  
  <p>Example with id_a=1</p>
  
  <pre><code>SELECT id_a
  FROM C
  WHERE id_b IN (SELECT id_b FROM B WHERE id_a=1)
  GROUP BY id_a;
  </code></pre>