SELECT
    corr_id,
    cam_id,
    chipRun.*
FROM flatcorrRun
JOIN flatcorrChipLink
    USING(corr_id)
JOIN chipRun
    USING(chip_id)
LEFT JOIN camRun
    ON chipRun.chip_id = camRun.chip_id
WHERE
    flatcorrRun.state = 'new'
    AND chipRun.state = 'full'
    AND camRun.cam_id is NULL;
