SELECT
    warp_id,
    diff_id,
    skycell_id,
    tess_id
FROM diffSkyfile
JOIN 
    (SELECT
        warp_id,
        diff_id,
        skycell_id,
        tess_id,
        diffSkyfile.fault
    FROM warpComplete 
    LEFT JOIN diffInputSkyfile
        USING(warp_id, skycell_id, tess_id)
    LEFT JOIN diffSkyfile
        USING(diff_id)
    WHERE 
        (diffInputSkyfile.template = 1 || diffInputSkyfile.template IS NULL)
    GROUP BY
        warpComplete.warp_id
    HAVING
        SUM(diffSkyfile.fault) = 0
        AND COUNT(warpComplete.warp_id) = COUNT(diffInputSkyfile.warp_id)
        AND COUNT(warpComplete.skycell_id) = COUNT(diffInputSkyfile.skycell_id)
        AND COUNT(warpComplete.tess_id) = COUNT(diffInputSkyfile.tess_id)
    ) as Foo
    USING(diff_id)
