title: Drupal 7 manually querying webforms DB tables
body: <p><strong>Can anyone give me an insight into what I'm doing wrong, please?</strong></p>
  
  <p>I have a webform of 32 components and I am trying to create XML of the submitted data. The form has been filled and submitted just once.</p>
  
  <pre><code>$query  =   db_select('webform_submitted_data', 'wsd');
  $query-&gt;join('webform_component', 'wc', 'wsd.cid = wc.cid');
  
  $query-&gt;fields('wsd', array('nid', 'cid', 'data', 'sid'));
  $query-&gt;fields('wc', array('form_key', 'name'));
  
  $results    =   $query-&gt;execute()-&gt;fetchAll();
  </code></pre>
  
  <p>As you can see, I am performing a join between 2 tables inorder to get the form_key for each filled webform component.</p>
  
  <p>The problem is I get alot more that 32 results - somehow the result is going badly wrong.</p>