title: mysql many-to-many query with where from another table
body: <p>This should be trivial, but my SQL chops are still pretty weak.
  I have setup an intermediate table for many-to-many queries in MySQL, let's call it 'item_packs' linking the 'packs' table with the 'items' table.
  I want to list all the 'items' where the entered 'pack_name' matches the name in the 'packs' table. </p>
  
  <pre>
  <h3>packs table</h3>packindex | packname (varchar) 
  ------------------------------
     1      |   todayspack
     2      |   anotherpack
  
  <h3>items table</h3>itemindex | itemname (varchar)
  ------------------------------
     1      |   firstitem
     2      |   anotheritem
  
  <h3>item_packs table</h3>   item   |   pack 
  ------------------------------
     1      |   2
     2      |   2
  
  </pre>
  
  <p>I almost have it:</p>
  
  <pre><code>SELECT c.*
  FROM items c
  JOIN item_packs j on j.item = c.itemindex
  JOIN packs t on j.pack = t.packindex
  where  j.pack= 1
  </code></pre>
  
  <p>It works if I enter the pack index (1) but I need to have that value come from the index in the 'packs' table where the pack name matches the entered pack name (todayspack).  </p>