SELECT DISTINCT
    chipProcessedImfile.chip_id,
    chipImfile.chip_imfile_id,
    chipProcessedImfile.class_id,
    chipProcessedImfile.uri,
    chipProcessedImfile.bg,
    chipProcessedImfile.bg_stdev,
    chipProcessedImfile.bg_mean_stdev,
    chipProcessedImfile.path_base,
    chipProcessedImfile.magicked,
    chipRun.state,
    chipRun.workdir,
    rawExp.exp_id,
    rawExp.exp_tag,
    rawExp.exp_name,
    rawExp.camera,
    rawExp.telescope,
    rawExp.filelevel
FROM chipRun
JOIN chipImfile
    USING(chip_id)
JOIN chipProcessedImfile
    USING(chip_id, class_id)
JOIN rawExp
    ON chipProcessedImfile.exp_id = rawExp.exp_id
