SELECT
    magic_ds_id,
    exp_id,
    re_place,
    camera,
    stage,
    stage_id,
    component,
    outroot,
    chipProcessedImfile.path_base,
    camProcessedExp.path_base AS cam_path_base,
    0 AS bytes,
    0 AS md5sum
FROM magicDSRun
    JOIN magicDSFile using(magic_ds_id)
    JOIN camProcessedExp using(cam_id)
    JOIN chipProcessedImfile ON (stage_id = chipProcessedImfile.chip_id AND component = class_id)
    JOIN rawExp using(exp_id)
WHERE magicDSRun.stage = 'chip'
    AND (magicDSRun.state = 'new' OR magicDSRun.state = 'censored')
    AND magicDSFile.fault > 0
