title: mysql check if value exist in group
body: <p>I have a table called <code>votes</code> with columns <code>id</code>, <code>image_id</code>, <code>user_id</code> and <code>time</code>. </p>
  
  <p>How can I add a bool in the result for if a specific <code>user_id</code> is one of the votes for each <code>image_id</code>?</p>
  
  <pre><code>SELECT image_id,
  count(image_id) as vote_count
  FROM votes
  GROUP BY image_id 
  ORDER BY vote_count DESC
  </code></pre>
  
  <p>I have tried <code>if(user_id = 18, 1, 0) as have_voted</code> but it does not work for each <code>image_id</code>.</p>