How do i delete both image_media_set and media_set table in the below where the count is greater than 1.
SELECT media_set.id,
(SELECT COUNT(*)
FROM image_media_set
WHERE image_media_set.media_set_id = media_set.id) AS imageCount
FROM media_set
INNER JOIN image_media_set
ON media_set.id = image_media_set.media_set_id
WHERE image_media_set.image_id = 6405;