<p>I have the following (shortened query):</p>

<pre><code>SELECT 
    `Statistics`.`StatisticID`,
    COUNT(DISTINCT `Flags`.`FlagType`) AS `FlagCount`
FROM `Statistics`
LEFT JOIN `Flags` ON `Statistics`.`StatisticID` = `Flags`.`StatisticID`
WHERE `FlagCount` = 0
GROUP BY `Statistics`.`StatisticID`
ORDER BY `SubmittedTime` DESC
LIMIT 0, 10
</code></pre>

<p>Now, neither <code>FlagCount = 0</code> or <code>COUNT(Flags.FlagType)</code> work in the <code>WHERE</code> clause. I thought about using a <code>SET</code> but I'm not sure how I'd add that to the query. Any ideas?</p>

<p>Thanks,</p>

Use
```
HAVING COUNT(DISTINCT Flags.FlagType) = 0
```
.