title: SQL Request on multiple tables
body: <p>I've put some information in this SQL Fiddle : <a href="http://www.sqlfiddle.com/#!2/0745c0/4/0" rel="nofollow">http://www.sqlfiddle.com/#!2/0745c0/4/0</a>
  You'll see table structure and my request.</p>
  
  <pre><code>SELECT
  cov.id AS cov_id,
  cov.utilisateurs_uid AS cov_uid,
  cov.timestamp_created as timestamp,
  cov.invisible as invisible,
  COALESCE(numreports, 0) AS numreports
  
  FROM
  cforge_covers AS cov
  LEFT OUTER JOIN cforge_votes AS vot ON cov.id = vot.covers_id AND vot.utilisateurs_uid != 123456789
  
  LEFT JOIN (SELECT rep.covers_id,
  COUNT(rep.id) AS numreports
  FROM  cforge_reports AS rep 
  GROUP BY rep.covers_id) reports ON reports.covers_id = cov.id
  
  WHERE invisible=0 AND (numreports &lt; 2 OR numreports IS null OR valide &gt; 0) AND cov.timestamp_created &gt; '1370815140' AND cov.timestamp_created &lt; '1373493540' GROUP BY cov.id
  
  ORDER BY rand() DESC LIMIT 0,2
  </code></pre>
  
  <p>When a user creates a picture, a line is created in cforge_covers, with his Facebook UID, ID of the picture and a timestamp.</p>
  
  <p>Cover pictures can be voted, once per user, and the votes ares stored in cforge_votes, where you can have the same covers_id multiple times and utilisateurs_uid (users_id) only once per covers_id max.</p>
  
  <p>Cover pictures can also be reported on the same basis as votes : once per user.</p>
  
  <p>The purpose of my request is to fetch :</p>
  
  <ul>
  <li>two random covers</li>
  <li>which haven't been reported or moderated (values stored in cforge_reports)</li>
  <li>for which the user hasn't already voted</li>
  </ul>
  
  <p>The last part is causing my problem : I try to exclude a specific utilisateurs_uid but as many users vote for an image, other votes for the cover make it valid to show even if the user has already voted for it.</p>
  
  <p>How can I write this request better ?</p>
  
  <p>Thanks in advance for your time !</p>