title: MySQL: Select nth rows where at least one has a attribute set?
body: <p>I’ve a table in MySQL called <strong>words</strong>.</p>
  
  <p>One column is called <strong>word</strong> (the actually word) and the other is called <strong>special</strong>  </p>
  
  <p>I’ve a query I’m trying to perform which - if possible - should do this:</p>
  
  <p><code>SELECT word FROM words WHERE special = 1 AT LEAST ONCE</code></p>
  
  <p>This is of cause a pseudo-like query but the thing I want is to get randomly nth records from my words table where AT LEAST ONE of the words has the attribute <strong>special</strong> set to 1.</p>
  
  <p>It means that all nth records is allowed to be 1 if this is the case or all but one of the nth records can have <strong>special</strong> = 0 but there have to be at least one which has the <strong>special</strong> = 1.</p>
  
  <p>I’ve tried something like:
  <code>SELECT * FROM words HAVING COUNT(isNum = 1) &gt; 1 ORDER BY RAND() LIMIT 10</code> or something like this.. It does not give me the result I want back, actually it only returns one result.</p>
  
  <p>Can this be done by SQL??</p>
  
  <p>Thanks</p>