Attaching additional queries to webforms
Webform has already this option, that you can find in the Submission settings. Otherwise, if you need to check something more you still can use some Webform hooks.

But if you need more complex submission checking, the best way from my point of view is to add a validate callback with the help of hook_form_alter().

Edit

Here is an example how to use the hook_form_alter(); For it, you must install the module Devel before.

// First you have to create your module
// you will find more information about it
// here http://drupal.org/node/231276
function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  // To add your validate callback to any form, you must find
  // the right form_id before
  // the form_id is an id that identify the form
  // from all that drupal can generate.
  // My solution to find it quickly its to show
  // all form_id with the help of Devel
  dsm($form, $form_id);
  // This will show you a drupal_set_message with something like that
  // form_id_form =&gt; Array()…
  // When you found the form that you want add the validate callback you
  // change it like that
  if($form_id == 'the_form_id') {
    $form['#validate'][] = 'mymodule_myvalidate';
  }
}

function mymodule_myvalidate(&amp;$form, &amp;$form_state) {
  // Here you can see want you receive
  // by checking the content of $form_state
  // still with Devel, like that
  dsm($form_state);

  // You should see the values in $form_state['values']
  // After you can make your additional checks and retur errors like that
  if($error) {
    form_set_error('field_error', t("You can balbla"));
    return;
  }
}