SELECT
    warpSkyfile.*,
    diffInputSkyfile.template,
    rawExp.camera
FROM diffRun
JOIN diffInputSkyfile
    USING(diff_id)
JOIN warpSkyfile
    ON  diffInputSkyfile.warp_id    = warpSkyfile.warp_id
    AND diffInputSkyfile.skycell_id = warpSkyfile.skycell_id
    AND diffInputSkyfile.tess_id    = warpSkyfile.tess_id
JOIN warpInputExp
    ON diffInputSkyfile.warp_id = warpInputExp.warp_id
JOIN camProcessedExp
    ON warpInputExp.cam_id = camProcessedExp.cam_id
JOIN chipProcessedExp
    ON camProcessedExp.chip_id = chipProcessedExp.chip_id
JOIN rawExp
    ON chipProcessedExp.exp_tag = rawExp.exp_tag
WHERE
    diffRun.state = 'run'

