1

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; 

1 Answer 1

1

That is the same than always delete the registry, is it not?

Is the COUNT really necessary?

Try this:

   DELETE FROM media_set, image_media_set
   WHERE image_media_set.media_set_id = media_set.id
   AND image_media_set.image_id = 6405;
Sign up to request clarification or add additional context in comments.

1 Comment

i need to delete where the count i greater than one

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.