--- relevance.module.old	2009-04-23 09:59:58.000000000 +0400
+++ relevance.module	2009-07-26 21:39:14.000000000 +0400
@@ -117,9 +117,11 @@
     foreach ($settings_voc as $vid => $voc) {
       if ($voc['enabled'] && !$checked_enabled) {
         $relevance      .= " * ";
-        $tables         .= ", {term_node} tn, {term_data} td";
+        $tables         .= " INNER JOIN {term_node} tn ON tn.nid = n.nid ";
+	$tables		.= " INNER JOIN {term_data} td ON td.tid = tn.tid ";
+	$tables		.= " INNER JOIN (SELECT tn.tid FROM {term_node} tn WHERE tn.nid = %d) as tids ON tids.tid = tn.tid ";
         // TODO: put joins here ?
-        $joins          .= "AND td.tid = tn.tid AND tn.nid = n.nid AND tn.tid in (SELECT tn.tid FROM {term_node} tn WHERE tn.nid = %d) ";
+        $joins          .= " ";
 	array_push($args, $nid);
         $checked_enabled = TRUE;
       }
