SELECT
    diffRun.skycell_id,
    diffRun.tess_id,
    diffRun.state,
    diffSkyfile.*,
    rawExp.exp_id,
    rawExp.camera,
    warpRun.warp_id
FROM diffRun
JOIN diffSkyfile
    USING(diff_id)
-- WS: my new stuff begins here
JOIN diffInputSkyfile
    ON diffInputSkyfile.diff_id = diffRun.diff_id
    AND diffInputSkyfile.template = 0
JOIN warpRun
    ON diffInputSkyfile.warp_id = warpRun.warp_id
JOIN fakeRun
    ON warpRun.fake_id = fakeRun.fake_id
JOIN camRun
    ON camRun.cam_id = fakeRun.cam_id
JOIN chipRun
    ON camRun.chip_id = chipRun.chip_id
JOIN rawExp
    ON chipRun.exp_id = rawExp.exp_id
