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.
$query = db_select('webform_submitted_data', 'wsd');
$query->join('webform_component', 'wc', 'wsd.cid = wc.cid');
$query->fields('wsd', array('nid', 'cid', 'data', 'sid'));
$query->fields('wc', array('form_key', 'name'));
$results = $query->execute()->fetchAll();
As you can see, I am performing a join between 2 tables in order to get the form_key for each filled webform component.
The problem is I get a lot more that 32 results - somehow the result is going badly wrong.