SELECT
    warpRun.warp_id,
    camProcessedExp.cam_id,
    warpRun.workdir,
    rawExp.camera
FROM warpRun
JOIN warpInputExp
    USING(warp_id)
JOIN camProcessedExp
    ON warpInputExp.cam_id = camProcessedExp.cam_id
JOIN chipRun
    ON camProcessedExp.chip_id = chipRun.chip_id
JOIN chipProcessedImfile
    ON chipRun.chip_id = chipProcessedImfile.chip_id
JOIN rawExp
    ON chipProcessedImfile.exp_id = rawExp.exp_id
LEFT JOIN warpSkyCellMap
    ON warpInputExp.warp_id = warpSkyCellMap.warp_id
    AND warpInputExp.cam_id = warpSkyCellMap.cam_id
WHERE
    warpRun.state = 'run'
    AND camProcessedExp.fault = 0
    AND warpSkyCellMap.warp_id IS NULL
    AND warpSkyCellMap.cam_id IS NULL
