UPDATE MEDIA
SET STATUS = 'OUTDATED'
WHERE BOOK_ID IN (
    SELECT M.BOOK_ID
    FROM MEDIA M
             LEFT JOIN MEDIA_PAGE MP on M.BOOK_ID = MP.BOOK_ID
    GROUP BY M.BOOK_ID, M.PAGE_COUNT
    HAVING M.PAGE_COUNT <> count(MP.BOOK_ID));
