And LEFT JOIN to actually get all results

This commit is contained in:
Mikael Nordfeldth 2016-02-12 00:05:36 +01:00
parent 1471defff3
commit 913595780f

View File

@ -40,7 +40,7 @@ require_once INSTALLDIR.'/scripts/commandline.inc';
print "Finding File entries that are not related to a Notice (or the notice has been deleted)...";
$file = new File();
$sql = 'SELECT file.* FROM file'.
' JOIN file_to_post ON file_to_post.file_id=file.id'.
' LEFT 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)'.