From 1471defff322bdf39554412f12738a46424b174d Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Thu, 11 Feb 2016 23:38:12 +0100 Subject: [PATCH] ...and avoid duplicate results... --- scripts/delete_orphan_files.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/delete_orphan_files.php b/scripts/delete_orphan_files.php index e11220b373..33293cfb8b 100755 --- a/scripts/delete_orphan_files.php +++ b/scripts/delete_orphan_files.php @@ -43,7 +43,8 @@ $sql = 'SELECT file.* FROM file'. ' JOIN file_to_post ON file_to_post.file_id=file.id'. ' WHERE'. ' NOT EXISTS (SELECT file_to_post.file_id FROM file_to_post WHERE file.id=file_to_post.file_id)'. - ' OR NOT EXISTS (SELECT notice.id FROM notice WHERE notice.id=file_to_post.post_id);'; + ' OR NOT EXISTS (SELECT notice.id FROM notice WHERE notice.id=file_to_post.post_id)'. + ' GROUP BY file.id;'; if ($file->query($sql) !== false) { print " {$file->N} found.\n"; -- 2.39.5