-- need to restrict to a single detRunSummary (require all to say 'cleaned'?)
SELECT
    detProcessedImfile.*
FROM detRunSummary
JOIN detProcessedImfile
    USING(det_id)
WHERE
    ((detRunSummary.data_state = 'goto_cleaned'
      AND detProcessedImfile.data_state = 'full')
     OR (detRunSummary.data_state = 'goto_scrubbed'
         AND detProcessedImfile.data_state = 'full')
     OR (detRunSummary.data_state = 'goto_purged'
         AND detProcessedImfile.data_state = 'full')
     OR detProcessedImfile.data_state = 'goto_cleaned'
     OR detProcessedImfile.data_state = 'goto_scrubbed'
     OR detProcessedImfile.data_state = 'goto_purged')
