 <p>You could use a <code>not exists</code> clause to ensure the combination has not been voted on:</p> <pre><code>select a.itemId , b.itemId from Items a join Items b on a.ItemId &lt; b.ItemId where not exists ( select * from Vote where userId = 42 and ((betterItemId = a.ItemId and worseItemId = b.ItemId) or (worseItemId = a.ItemId and betterItemId = b.ItemId)) ) order by rand() limit 2 </code></pre>