Select from table1 on condition specific elements from table1 don't exist in table2
<p>table <code>words</code> contains columns: <code>word_id</code> <code>word</code></p>

<p>My query prints as:</p>

<p><code>SELECT word FROM words WHERE condition1 AND condition2 ORDER BY RAND() LIMIT 5000</code></p>

<p>table <code>solved</code> contains columns: <code>user_id</code> <code>word_id</code> </p>

<p>I'd like to fetch 5000 random rows, on condition that none of them is found in table <code>solved</code> for <code>user = username</code></p>

<p>So far I've tried:</p>

<pre><code>SELECT word FROM words w 
WHERE not exists 
(select 1 from solved s where s.word_id = w.word_id 
AND s.user_id = 'username') 
AND condition1 AND condition2 ORDER BY RAND() LIMIT 5000
</code></pre>