SELECT
    magic_id,
    uri
FROM magicRun
JOIN magicTree
    USING(magic_id)
LEFT JOIN magicNodeResult
    USING(magic_id, node)
WHERE
    magicRun.state = 'run'
    AND magicNodeResult.node = 'root'
    AND magicNodeResult.fault = 0
GROUP BY
    magic_id
HAVING
    COUNT(magicTree.node) = COUNT(magicNodeResult.node)
