--- database.mysqli.inc.orig	2008-01-04 01:42:19.000000000 -0600
+++ database.mysqli.inc	2008-01-03 22:53:42.000000000 -0600
@@ -415,7 +415,7 @@
 function db_distinct_field($table, $field, $query) {
   $field_to_select = 'DISTINCT('. $table .'.'. $field .')';
   // (?<!text) is a negative look-behind (no need to rewrite queries that already use DISTINCT).
-  $pattern = '/(SELECT.*)(?:'. $table .'\.|\s)(?<!DISTINCT\()(?<!DISTINCT\('. $table .'\.)'. $field .'(.*FROM )/AUsi';
+  $pattern = '/(SELECT.*)(?:\b'. $table .'\.|\s)(?<!DISTINCT\()(?<!DISTINCT\(\b'. $table .'\.)'. $field .'(.*FROM )/AUsi';
   return preg_replace($pattern, '\1 '. $field_to_select .'\2', $query);
 }
 
