Index: trunk/ippTools/src/camtool.c
===================================================================
--- trunk/ippTools/src/camtool.c	(revision 26981)
+++ trunk/ippTools/src/camtool.c	(revision 27133)
@@ -686,7 +686,17 @@
     PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id",    "==");
     pxAddLabelSearchArgs (config, where, "-label",    "camRun.label",     "==");
+    pxAddLabelSearchArgs (config, where, "-data_group", "camRun.data_group",     "LIKE");
     PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "==");
 
-    if (!psListLength(where->list) &&
+    psString where2 = NULL;
+    if (!pxspaceAddWhere(config, &where2, "rawExp")) {
+        psError(psErrorCodeLast(), false, "pxSpaceAddWhere failed");
+        return false;
+    }
+    if (!pxmagicAddWhere(config, &where2, "chipRun")) {
+        psError(psErrorCodeLast(), false, "pxSpaceAddWhere failed");
+        return false;
+    }
+    if (!psListLength(where->list) && !where2 &&
         !psMetadataLookupBool(NULL, config->args, "-all")) {
         psFree(where);
@@ -725,7 +735,11 @@
     }
     psFree(where);
+    if (where2) {
+        psStringAppend(&query, " %s", where2);
+        psFree(where2);
+    }
 
     // order by cam_id so that the postage stamp parser can easliy find the 'latest' astrometry
-    psStringAppend(&query, " ORDER BY cam_id");
+    psStringAppend(&query, " ORDER BY exp_id, cam_id");
 
     // treat limit == 0 as "no limit"
