1

如何删除下面计数大于 1 的 image_media_set 和 media_set 表。

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; 
4

1 回答 1

1

这和总是删除注册表一样,不是吗?

COUNT 真的有必要吗?

尝试这个:

   DELETE FROM media_set, image_media_set
   WHERE image_media_set.media_set_id = media_set.id
   AND image_media_set.image_id = 6405;
于 2013-01-15T19:47:47.463 回答