How can I create a view that lists users who have NOT completed an order? I am helping with a Drupal 6 / Ubercart site that has tons of spam user accounts registered.

I want to create a view that will list spam accounts. My thinking is that users who have registered but never bought anything in Ubercart have a high probability of being spam so I want to create this view. However, I can't figure out how to filter my user view to list only users who have not completed an order.

Is this possible?
To save to anyone else the trouble, this is the view I created to achieve the above.

$view = new view;
$view-&gt;name = 'Spambots';
$view-&gt;description = '';
$view-&gt;tag = '';
$view-&gt;base_table = 'users';
$view-&gt;core = 6;
$view-&gt;api_version = '2';
$view-&gt;disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view-&gt;new_display('default', 'Defaults', 'default');
$handler-&gt;override_option('relationships', array(
  'uid' =&gt; array(
    'label' =&gt; 'Order user',
    'required' =&gt; 0,
    'id' =&gt; 'uid',
    'table' =&gt; 'uc_orders',
    'field' =&gt; 'uid',
    'relationship' =&gt; 'none',
  ),
));
$handler-&gt;override_option('fields', array(
  'mail' =&gt; array(
    'label' =&gt; 'E-mail',
    'alter' =&gt; array(
      'alter_text' =&gt; 0,
      'text' =&gt; '',
      'make_link' =&gt; 0,
      'path' =&gt; '',
      'absolute' =&gt; 0,
      'link_class' =&gt; '',
      'alt' =&gt; '',
      'rel' =&gt; '',
      'prefix' =&gt; '',
      'suffix' =&gt; '',
      'target' =&gt; '',
      'help' =&gt; '',
      'trim' =&gt; 0,
      'max_length' =&gt; '',
      'word_boundary' =&gt; 1,
      'ellipsis' =&gt; 1,
      'html' =&gt; 0,
      'strip_tags' =&gt; 0,
    ),
    'empty' =&gt; '',
    'hide_empty' =&gt; 0,
    'empty_zero' =&gt; 0,
    'hide_alter_empty' =&gt; 1,
    'link_to_user' =&gt; 'mailto',
    'exclude' =&gt; 0,
    'id' =&gt; 'mail',
    'table' =&gt; 'users',
    'field' =&gt; 'mail',
    'relationship' =&gt; 'none',
  ),
  'created' =&gt; array(
    'label' =&gt; 'Created date',
    'alter' =&gt; array(
      'alter_text' =&gt; 0,
      'text' =&gt; '',
      'make_link' =&gt; 0,
      'path' =&gt; '',
      'absolute' =&gt; 0,
      'link_class' =&gt; '',
      'alt' =&gt; '',
      'rel' =&gt; '',
      'prefix' =&gt; '',
      'suffix' =&gt; '',
      'target' =&gt; '',
      'help' =&gt; '',
      'trim' =&gt; 0,
      'max_length' =&gt; '',
      'word_boundary' =&gt; 1,
      'ellipsis' =&gt; 1,
      'html' =&gt; 0,
      'strip_tags' =&gt; 0,
    ),
    'empty' =&gt; '',
    'hide_empty' =&gt; 0,
    'empty_zero' =&gt; 0,
    'hide_alter_empty' =&gt; 1,
    'date_format' =&gt; 'small',
    'custom_date_format' =&gt; '',
    'exclude' =&gt; 0,
    'id' =&gt; 'created',
    'table' =&gt; 'users',
    'field' =&gt; 'created',
    'relationship' =&gt; 'none',
  ),
  'login' =&gt; array(
    'label' =&gt; 'Last login',
    'alter' =&gt; array(
      'alter_text' =&gt; 0,
      'text' =&gt; '',
      'make_link' =&gt; 0,
      'path' =&gt; '',
      'absolute' =&gt; 0,
      'link_class' =&gt; '',
      'alt' =&gt; '',
      'rel' =&gt; '',
      'prefix' =&gt; '',
      'suffix' =&gt; '',
      'target' =&gt; '',
      'help' =&gt; '',
      'trim' =&gt; 0,
      'max_length' =&gt; '',
      'word_boundary' =&gt; 1,
      'ellipsis' =&gt; 1,
      'html' =&gt; 0,
      'strip_tags' =&gt; 0,
    ),
    'empty' =&gt; '',
    'hide_empty' =&gt; 0,
    'empty_zero' =&gt; 0,
    'hide_alter_empty' =&gt; 1,
    'date_format' =&gt; 'small',
    'custom_date_format' =&gt; '',
    'exclude' =&gt; 0,
    'id' =&gt; 'login',
    'table' =&gt; 'users',
    'field' =&gt; 'login',
    'relationship' =&gt; 'none',
  ),
  'edit_node' =&gt; array(
    'label' =&gt; 'Edit link',
    'alter' =&gt; array(
      'alter_text' =&gt; 0,
      'text' =&gt; '',
      'make_link' =&gt; 0,
      'path' =&gt; '',
      'absolute' =&gt; 0,
      'link_class' =&gt; '',
      'alt' =&gt; '',
      'rel' =&gt; '',
      'prefix' =&gt; '',
      'suffix' =&gt; '',
      'target' =&gt; '',
      'help' =&gt; '',
      'trim' =&gt; 0,
      'max_length' =&gt; '',
      'word_boundary' =&gt; 1,
      'ellipsis' =&gt; 1,
      'html' =&gt; 0,
      'strip_tags' =&gt; 0,
    ),
    'empty' =&gt; '',
    'hide_empty' =&gt; 0,
    'empty_zero' =&gt; 0,
    'hide_alter_empty' =&gt; 1,
    'text' =&gt; '',
    'exclude' =&gt; 0,
    'id' =&gt; 'edit_node',
    'table' =&gt; 'users',
    'field' =&gt; 'edit_node',
    'relationship' =&gt; 'none',
  ),
  'delete_node' =&gt; array(
    'label' =&gt; 'Delete link',
    'alter' =&gt; array(
      'alter_text' =&gt; 0,
      'text' =&gt; '',
      'make_link' =&gt; 0,
      'path' =&gt; '',
      'absolute' =&gt; 0,
      'link_class' =&gt; '',
      'alt' =&gt; '',
      'rel' =&gt; '',
      'prefix' =&gt; '',
      'suffix' =&gt; '',
      'target' =&gt; '',
      'help' =&gt; '',
      'trim' =&gt; 0,
      'max_length' =&gt; '',
      'word_boundary' =&gt; 1,
      'ellipsis' =&gt; 1,
      'html' =&gt; 0,
      'strip_tags' =&gt; 0,
    ),
    'empty' =&gt; '',
    'hide_empty' =&gt; 0,
    'empty_zero' =&gt; 0,
    'hide_alter_empty' =&gt; 1,
    'text' =&gt; '',
    'exclude' =&gt; 0,
    'id' =&gt; 'delete_node',
    'table' =&gt; 'users',
    'field' =&gt; 'delete_node',
    'relationship' =&gt; 'none',
  ),
));
$handler-&gt;override_option('sorts', array(
  'uid' =&gt; array(
    'order' =&gt; 'DESC',
    'id' =&gt; 'uid',
    'table' =&gt; 'users',
    'field' =&gt; 'uid',
    'relationship' =&gt; 'none',
  ),
));
$handler-&gt;override_option('filters', array(
  'order_id' =&gt; array(
    'operator' =&gt; 'empty',
    'value' =&gt; array(
      'value' =&gt; '',
      'min' =&gt; '',
      'max' =&gt; '',
    ),
    'group' =&gt; '0',
    'exposed' =&gt; FALSE,
    'expose' =&gt; array(
      'operator' =&gt; FALSE,
      'label' =&gt; '',
    ),
    'id' =&gt; 'order_id',
    'table' =&gt; 'uc_orders',
    'field' =&gt; 'order_id',
    'relationship' =&gt; 'none',
  ),
  'rid' =&gt; array(
    'operator' =&gt; 'not',
    'value' =&gt; array(
      3 =&gt; '3',
      6 =&gt; '6',
      4 =&gt; '4',
      5 =&gt; '5',
    ),
    'group' =&gt; '0',
    'exposed' =&gt; FALSE,
    'expose' =&gt; array(
      'operator' =&gt; FALSE,
      'label' =&gt; '',
    ),
    'id' =&gt; 'rid',
    'table' =&gt; 'users_roles',
    'field' =&gt; 'rid',
    'relationship' =&gt; 'none',
    'reduce_duplicates' =&gt; 0,
  ),
));
$handler-&gt;override_option('access', array(
  'type' =&gt; 'role',
  'role' =&gt; array(
    3 =&gt; 3,
    5 =&gt; 5,
  ),
));
$handler-&gt;override_option('cache', array(
  'type' =&gt; 'none',
));
$handler-&gt;override_option('header', 'The following accounts have no orders associated with them and are not assigned a specific role. Therefore it is safe to assume they are spambots.');
$handler-&gt;override_option('header_format', '1');
$handler-&gt;override_option('header_empty', 1);
$handler-&gt;override_option('use_ajax', TRUE);
$handler-&gt;override_option('items_per_page', 20);
$handler-&gt;override_option('use_pager', '1');
$handler-&gt;override_option('style_plugin', 'table');
$handler-&gt;override_option('style_options', array(
  'grouping' =&gt; '',
  'override' =&gt; 1,
  'sticky' =&gt; 0,
  'order' =&gt; 'asc',
  'summary' =&gt; '',
  'columns' =&gt; array(
    'mail' =&gt; 'mail',
    'login' =&gt; 'login',
    'uid' =&gt; 'uid',
    'delete_node' =&gt; 'delete_node',
  ),
  'info' =&gt; array(
    'mail' =&gt; array(
      'sortable' =&gt; 0,
      'separator' =&gt; '',
    ),
    'login' =&gt; array(
      'sortable' =&gt; 0,
      'separator' =&gt; '',
    ),
    'uid' =&gt; array(
      'sortable' =&gt; 0,
      'separator' =&gt; '',
    ),
    'delete_node' =&gt; array(
      'separator' =&gt; '',
    ),
  ),
  'default' =&gt; '-1',
));
$handler = $view-&gt;new_display('page', 'Page', 'page_1');
$handler-&gt;override_option('path', 'spambots');
$handler-&gt;override_option('menu', array(
  'type' =&gt; 'none',
  'title' =&gt; '',
  'description' =&gt; '',
  'weight' =&gt; 0,
  'name' =&gt; 'navigation',
));
$handler-&gt;override_option('tab_options', array(
  'type' =&gt; 'none',
  'title' =&gt; '',
  'description' =&gt; '',
  'weight' =&gt; 0,
  'name' =&gt; 'navigation',
));


It will need tweaking to your needs because I've got it set up to filter based on user role too but should give you a good base to start with.

Also the SQL is:

SELECT users.uid AS uid, users.mail AS users_mail FROM users users  LEFT JOIN uc_orders uc_orders ON users.uid = uc_orders.uid LEFT JOIN users users_uc_orders ON uc_orders.uid = users_uc_orders.uid LEFT JOIN users_roles users_roles ON users.uid = users_roles.uid AND (users_roles.rid = 3 OR users_roles.rid = 6 OR users_roles.rid = 4 OR users_roles.rid = 5) WHERE (uc_orders.order_id IS NULL) AND (users_roles.rid IS NULL) ORDER BY uid DESC