SELECT
    detNormalizedImfile.*
FROM detRunSummary
JOIN detNormalizedImfile
    USING(det_id,iteration)
WHERE
    ((detRunSummary.data_state = 'goto_cleaned'
      AND detNormalizedImfile.data_state = 'full')
     OR (detRunSummary.data_state = 'goto_scrubbed'
      AND detNormalizedImfile.data_state = 'full')
     OR (detRunSummary.data_state = 'goto_purged'
      AND detNormalizedImfile.data_state = 'full')
     OR detNormalizedImfile.data_state = 'goto_cleaned'
     OR detNormalizedImfile.data_state = 'goto_scrubbed'
     OR detNormalizedImfile.data_state = 'goto_purged')

