SELECT
    magic_id,
    exp_id,
    camera,
    magicRun.workdir,
    ra,
    decl,
    diffRun.tess_id
FROM magicRun
JOIN diffRun USING(diff_id)
JOIN rawExp USING(exp_id)
LEFT JOIN magicTree
    USING(magic_id)
WHERE
    magicRun.state = 'new'
    AND magicTree.node IS NULL
    AND magicRun.fault = 0
