Index: trunk/ippTools/src/difftool.c
===================================================================
--- trunk/ippTools/src/difftool.c	(revision 25514)
+++ trunk/ippTools/src/difftool.c	(revision 25515)
@@ -583,7 +583,8 @@
     }
 
+    psString whereString = psStringCopy("");
     if (psListLength(where->list)) {
         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
-        psStringAppend(&query, " WHERE %s", whereClause);
+        psStringAppend(&whereString, "\n AND %s", whereClause);
         psFree(whereClause);
     }
@@ -599,10 +600,12 @@
     if (!psDBTransaction(config->dbh)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
-        return false;
-    }
-
-    if (!p_psDBRunQuery(config->dbh, query)) {
+        psFree(whereString);
+        return false;
+    }
+
+    if (!p_psDBRunQueryF(config->dbh, query, whereString)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         psFree(query);
+        psFree(whereString);
         if (!psDBRollback(config->dbh)) {
             psError(PS_ERR_UNKNOWN, false, "database error");
@@ -611,4 +614,5 @@
     }
     psFree(query);
+    psFree(whereString);
 
     psArray *output = p_psDBFetchResult(config->dbh);
