Index: branches/eam_branches/ipp-20230313/ippTools/share/xcfftool_definebyquery.sql
===================================================================
--- branches/eam_branches/ipp-20230313/ippTools/share/xcfftool_definebyquery.sql	(revision 42591)
+++ branches/eam_branches/ipp-20230313/ippTools/share/xcfftool_definebyquery.sql	(revision 42594)
@@ -13,10 +13,18 @@
     JOIN skycell                USING (tess_id, skycell_id)
     -- join hook %s
+    -- for no-rerun:
+    -- LEFT JOIN xcForceRun ON xcForceRun.xccal_id = %s.xccalRun.xccal_id
 WHERE 
-    %s.xcstackCamera.camera = 'test_cam1' AND
+    -- the first %s below should be filled with the xcamera database
+    -- the second should be the name of the camera corresponding to the
+    -- database in which the tool is run
+    %s.xcstackCamera.camera = '%s' AND
     %s.xccalRun.state = 'full' AND
     %s.xccalResult.quality = 0
-
+-- 'where' string is appended here
+    -- for no-rerun, also append:
+    -- AND xcff_id IS NULL
 
 -- this query is run in the database in which the original stacks were made (e.g., gpc1)
--- it refers to the database used to generate the xcstacks (e.g., xcamera)
+-- the external database (%s in front of the xcstackRun & xccalRun tables) refers to the database
+-- used to generate the xcstacks (e.g., xcamera)
