SELECT DISTINCT
    detStackedImfile.*,
    rawExp.camera
FROM detRunSummary
JOIN detStackedImfile
     USING(det_id,iteration)
JOIN detInputExp
     USING(det_id,iteration)
JOIN rawExp
     USING(exp_id)
WHERE
    ((detRunSummary.data_state = 'goto_cleaned'
      AND detStackedImfile.data_state = 'full')
     OR (detRunSummary.data_state = 'goto_scrubbed'
      AND detStackedImfile.data_state = 'full')
     OR (detRunSummary.data_state = 'goto_purged'
      AND detStackedImfile.data_state = 'full')
     OR detStackedImfile.data_state = 'goto_cleaned'
     OR detStackedImfile.data_state = 'goto_scrubbed'
     OR detStackedImfile.data_state = 'goto_purged')
