Index: /trunk/ippTools/share/addtool_find_sky_id.sql
===================================================================
--- /trunk/ippTools/share/addtool_find_sky_id.sql	(revision 31595)
+++ /trunk/ippTools/share/addtool_find_sky_id.sql	(revision 31596)
@@ -3,6 +3,6 @@
 FROM 
      staticskyResult
-join staticSkyRun using (sky_id)
-join staticSkyInput using (stack_id)
+join staticskyRun using (sky_id)
+join staticskyInput using(sky_id)
 JOIN stackRun USING(stack_id)
 
@@ -13,5 +13,5 @@
           ) as foo
      ON sky_id = added_sky_id 
-     AND stage = 'sky'
+     AND stage = 'staticsky'
      -- hook for qualifying the join on the previous_dvodb
      AND %s
Index: /trunk/ippTools/share/addtool_find_sky_id_dvo.sql
===================================================================
--- /trunk/ippTools/share/addtool_find_sky_id_dvo.sql	(revision 31595)
+++ /trunk/ippTools/share/addtool_find_sky_id_dvo.sql	(revision 31596)
@@ -1,4 +1,7 @@
 SELECT staticskyRun.* FROM staticskyResult
 JOIN staticskyRun USING(sky_id)
+join staticskyInput using(sky_id)
+JOIN stackRun USING(stack_id)
+
 WHERE staticskyRun.state = 'full' and staticskyResult.quality = 0
     AND sky_id NOT IN (SELECT sky_id
Index: /trunk/ippTools/src/addtool.c
===================================================================
--- /trunk/ippTools/src/addtool.c	(revision 31595)
+++ /trunk/ippTools/src/addtool.c	(revision 31596)
@@ -117,5 +117,5 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxcamGetSearchArgs (config, where);
+    //  pxcamGetSearchArgs (config, where);
     PXOPT_COPY_S64(config->args, where,  "-cam_id",    "camRun.cam_id", "==");
     PXOPT_COPY_S64(config->args, where,  "-stack_id",    "stackRun.stack_id", "==");
@@ -123,7 +123,8 @@
     PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
     if (strcmp(stage, "cam")== 0) {
-
+      pxcamGetSearchArgs (config, where);
     pxAddLabelSearchArgs (config, where, "-label",     "camRun.label", "=="); // define using camRun label
     pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label
+
     PXOPT_COPY_STR(config->args, where,  "-reduction", "camRun.reduction", "==");
     }
@@ -133,4 +134,5 @@
     pxAddLabelSearchArgs (config, where, "-data_group","stackRun.data_group", "=="); // define using camRun label
     PXOPT_COPY_STR(config->args, where,  "-reduction", "stackRun.reduction", "==");
+    pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
     }
     if (strcmp(stage, "staticsky")== 0) {
@@ -139,4 +141,5 @@
     pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label
     PXOPT_COPY_STR(config->args, where,  "-reduction", "staticskyyRun.reduction", "==");
+    pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
     }
     
Index: /trunk/ippTools/src/addtoolConfig.c
===================================================================
--- /trunk/ippTools/src/addtoolConfig.c	(revision 31595)
+++ /trunk/ippTools/src/addtoolConfig.c	(revision 31596)
@@ -56,4 +56,5 @@
     psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by camRun label", NULL);
     psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-data_group", PS_META_DUPLICATE_OK, "search by camRun data_group", NULL);
+    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-filter", PS_META_DUPLICATE_OK, "search by filter", NULL);
     psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction",          0, "search by camRun reduction class", NULL);
     psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-destreaked",           0, "only queue destreaked runs", false);
