SELECT *
FROM (
-- Single skycells
SELECT
    magicRun.magic_id,
    magicRun.state,
    magicInputSkyfile.node,
    diffSkyfile.uri,
    diffSkyfile.fault
FROM magicInputSkyfile
JOIN diffSkyfile
    USING(diff_id)
JOIN magicRun
    USING(magic_id)
UNION
-- Merged skycells
SELECT
    magicRun.magic_id,
    magicRun.state,
    magicTree.node,
    magicNodeResult.uri,
    magicNodeResult.fault
FROM magicTree
JOIN magicRun
    USING(magic_id)
JOIN magicNodeResult
    ON magicTree.magic_id = magicNodeResult.magic_id
    AND magicTree.dep = magicNodeResult.node
) as Foo
WHERE
    fault = 0
