Index: trunk/ippTools/src/difftool.c
===================================================================
--- trunk/ippTools/src/difftool.c	(revision 37947)
+++ trunk/ippTools/src/difftool.c	(revision 37974)
@@ -1235,5 +1235,5 @@
 
   PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
-  PXOPT_COPY_STR(config->args, where, "-filter", "filter", "==");
+  PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "==");
   PXOPT_COPY_STR(config->args, where, "-comment", "comment", "LIKE");
   PXOPT_COPY_S64(config->args, where, "-warp_id", "warpRun.warp_id", "==");
@@ -1284,18 +1284,20 @@
 
   psString whereClause = psDBGenerateWhereConditionSQL(where,NULL);
+  psString diffWhereClause = psStringCopy("");
+  psString joinWhereClause = psStringCopy("");
   
   // Don't queue things that already have diffs.
   if (! (reRun || newTemplates) ) {
-    psStringAppend(&whereClause, "\nAND diff_id IS NULL\n");
+    psStringAppend(&joinWhereClause, "\nAND diff_id IS NULL\n");
   }
   // Append diff qualifiers, if we have them
   if (label) {
-    psStringAppend(&whereClause, "\nAND ((diffRun.label = '%s') OR (diffRun.label IS NULL))",label);
+    psStringAppend(&diffWhereClause, "\nAND ((diffRun.label = '%s') OR (diffRun.label IS NULL))",label);
   }
   if (data_group) {
-    psStringAppend(&whereClause, "\nAND ((diffRun.data_group = '%s') OR (diffRun.data_group IS NULL))",data_group);
+    psStringAppend(&diffWhereClause, "\nAND ((diffRun.data_group = '%s') OR (diffRun.data_group IS NULL))",data_group);
   }
   if (reduction) {
-    psStringAppend(&whereClause, "\nAND ((diffRun.reduction = '%s') OR (diffRun.reduction IS NULL))",reduction);
+    psStringAppend(&diffWhereClause, "\nAND ((diffRun.reduction = '%s') OR (diffRun.reduction IS NULL))",reduction);
   }
 
@@ -1305,5 +1307,5 @@
 
   // This is just a simple query, so we don't need to do a transaction
-  if (!p_psDBRunQueryF(config->dbh, query, whereClauseString)) {
+  if (!p_psDBRunQueryF(config->dbh, query, whereClauseString, diffWhereClause,joinWhereClause)) {
     psError(PS_ERR_UNKNOWN, false, "database error");
     psFree(query);
