
UPDATE
  photos
SET
  status = 5
WHERE
  photoid IN (
    SELECT
      SUBSTRING_INDEX(event, '#', -1)
    FROM
      `adminlog`
    WHERE
      created_at > '2021-08-19'
      AND userid = 4
      AND event LIKE 'Changed the status of photo #%'
      AND new_value = '"approved"'
  )
