Index: content_taxonomy_autocomplete.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_taxonomy/content_taxonomy_autocomplete.module,v
retrieving revision 1.2
diff -u -r1.2 content_taxonomy_autocomplete.module
--- content_taxonomy_autocomplete.module	16 Feb 2007 11:48:01 -0000	1.2
+++ content_taxonomy_autocomplete.module	25 Feb 2007 15:43:26 -0000
@@ -167,20 +167,23 @@
   $last_string = trim(array_pop($array));
   if ($last_string != '') {
     if ($tid) {
-      $result = db_query_range("SELECT t.name FROM {term_data} t, {term_synonym} s, {term_hierarchy} h 
-        WHERE h.parent = %d AND h.tid = t.tid
-        AND (LOWER(t.name) LIKE LOWER('%%%s%%') OR (t.tid = s.tid AND LOWER(s.name) LIKE LOWER('%%%s%%')))",
+      $result = db_query_range(db_rewrite_sql("SELECT t.name FROM {term_data} t 
+        LEFT JOIN {term_synonym} s ON t.tid = s.tid
+        INNER JOIN {term_hierarchy} h ON  t.tid = h.tid
+        WHERE h.parent = %d 
+        AND (LOWER(t.name) LIKE LOWER('%%%s%%') OR LOWER(s.name) LIKE LOWER('%%%s%%'))", 't', 'tid'),
         $tid,$last_string,$last_string,0,10);
     }
     else {
-      $result = db_query_range("SELECT t.name FROM {term_data} t, {term_synonym} s 
+      $result = db_query_range(db_rewrite_sql("SELECT t.name FROM {term_data} t 
+        LEFT JOIN {term_synonym} s ON t.tid = s.tid
         WHERE t.vid = %d 
-        AND (LOWER(t.name) LIKE LOWER('%%%s%%') OR (t.tid = s.tid AND LOWER(s.name) LIKE LOWER('%%%s%%')))",
-        $vid,$last_string,$last_string,0,10);
+        AND (LOWER(t.name) LIKE LOWER('%%%s%%') OR LOWER(s.name) LIKE LOWER('%%%s%%'))", 't', 'tid'),
+        $vid, $last_string, $last_string, 0, 10);
     }
       
     if ($multiple) {
-      $prefix = count($array) ? implode(',', $array) .',' : '';
+      $prefix = count($array) ? implode(', ', $array) .', ' : '';
     }
     else {
       $prefix = '';
