To be complete, this is my current code:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('COUNT(*)');
$query->from($db->quoteName('#__cck_mytablename'));
$query->where($db->quoteName('dnt_trid') ." = " . $fields['dnt_trid']->value . " AND " . $db->quoteName('dnt_user') ." = " . $fields['dnt_user']->value);
// Reset the query using our newly populated query object.
$db->setQuery($query);
$count = $db->loadResult();
// warning if record(s) found
if($count > 0){
// throw error
$error = "Deze deelnemer is reeds aan dit traject gekoppeld!";
JFactory::getApplication()->redirect($fields['sysdisplayfield']->value, $error, 'warning');
}