diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a598d6a83d6..fd358a04717 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6739,10 +6739,11 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) { if ($val) { - $newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' LIKE \'' . $db->escape(trim($val)) . ',%\''; + $newres .= ($i2 > 0 ? ' OR (' : '(') . $field . ' LIKE \'' . $db->escape(trim($val)) . ',%\''; $newres .= ' OR '. $field . ' = \'' . $db->escape(trim($val)) . '\''; $newres .= ' OR '. $field . ' LIKE \'%,' . $db->escape(trim($val)) . '\''; $newres .= ' OR '. $field . ' LIKE \'%,' . $db->escape(trim($val)) . ',%\''; + $newres .= ')'; $i2++; } }