title: Check if all ID's in a Column have a specific value in another column, different tables
body: <p>I have two tables:</p>
  
  <p>Table 1:</p>
  
  <pre><code>Id 
  1232
  1344
  1313
  4242
  3242
  555
  </code></pre>
  
  <p>Table 2:</p>
  
  <pre><code>Id    sym    mnth  code
  1232    9      1     32
  1344    15     1     14
  1313    10     1     32
  4242    11     1     32
  3242    9      1     32
  1232    9      2     32
  1344    13     2     14
  1313    9      2     32
  4242    10     2     32
  3242    9      2     32
  </code></pre>
  
  <p>I want to check if all the id's in table 1 have the value 9 in sym for all the month (1,2 in the example) but only for those id's which for them the code in table 2 is '32'.</p>
  
  <p>If not return me the id and the months for which the 9 is missing separate by a comma. If Id in table 1 doesn't exists at all in table 2 return null in the month column and the id.</p>
  
  <p>The output in the example should be:</p>
  
  <pre><code>ID    month
  1313    1
  4242    1,2
  555    NULL
  
  1344 doesn't exist because the code column for hime is not 32.
  </code></pre>
  
  <p>I started writing this: </p>
  
  <pre><code>SELECT table1.id
  FROM table1
  WHERE not EXISTS (SELECT id FROM table2 
                    WHERE table2.sml = '9' AND table2.code = 32)
  </code></pre>
  
  <p>But I really don't know how to make the query run for all month and plug the results like I've mentioned in the output. Any help? </p>
  
  <p>Thank you!</p>