Index: trunk/ippTools/src/chiptool.c
===================================================================
--- trunk/ippTools/src/chiptool.c	(revision 19334)
+++ trunk/ippTools/src/chiptool.c	(revision 19339)
@@ -120,5 +120,6 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxchipGetSearchArgs (config, where);
+    pxchipGetSearchArgs (config, where); // rawExp only
+    PXOPT_COPY_STR(config->args, where, "-label", "rawExp.label", "LIKE");
 
     if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
@@ -232,6 +233,6 @@
 
     psMetadata *where = psMetadataAlloc();
-    PXOPT_COPY_S64(config->args,  where, "-chip_id", "chip_id", "==");
-    pxchipGetSearchArgs (config, where);
+    pxchipGetSearchArgs (config, where); // rawExp, chipRun
+    PXOPT_COPY_S64(config->args,  where, "-chip_id", "chipRun.chip_id", "==");
 
     if (!psListLength(where->list)
@@ -282,6 +283,6 @@
 
     psMetadata *where = psMetadataAlloc();
+    pxchipGetSearchArgs (config, where); //chipRun, rawExp
     PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "==");
-    pxchipGetSearchArgs (config, where);
 
     psString query = pxDataGet("chiptool_pendingimfile.sql");
@@ -454,7 +455,9 @@
 
     psMetadata *where = psMetadataAlloc();
+    pxchipGetSearchArgs (config, where); // chipRun, chipProcessedImfile, rawExp
     PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "==");
     PXOPT_COPY_STR(config->args, where, "-class_id", "chipProcessedImfile.class_id", "==");
-    pxchipGetSearchArgs (config, where);
+    PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "==");
+    PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "LIKE");
 
     psString query = pxDataGet("chiptool_processedimfile.sql");
@@ -521,9 +524,9 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxchipGetSearchArgs (config, where);
-
-    // from chipRun (XXX is missing from sql)
+    pxchipGetSearchArgs (config, where); // chipProcessedImfile, rawExp
+    PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "==");
+    PXOPT_COPY_STR(config->args, where, "-class_id", "chipProcessedImfile.class_id", "==");
+    PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "LIKE");
     PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "==");
-    PXOPT_COPY_STR(config->args, where, "-label",     "chipRun.label", "==");
     PXOPT_COPY_S16(config->args, where, "-code", "chipProcessedImfile.fault", "=");
 
@@ -565,6 +568,8 @@
 
     psMetadata *where = psMetadataAlloc();
+    pxchipGetSearchArgs (config, where); // chipProcessedImfile
     PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
-    pxchipGetSearchArgs (config, where);
+    PXOPT_COPY_S64(config->args, where, "-class_id", "class_id", "==");
+    PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "==");
     PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
 
