title: MySQL find words containing all letters at any place
body: <p>With the following query</p>
  
  <pre><code>SELECT * FROM words WHERE word REGEXP '(ord)'
  </code></pre>
  
  <ul>
  <li>This will return words like <em><code>ford</code>, <code>lord</code>, <code>word</code></em></li>
  </ul>
  
  <p>How can I include words where these letters appear but not in the same order? </p>
  
  <ul>
  <li>For example <em><code>adore</code>, <code>door</code>, <code>random</code></em></li>
  </ul>
  
  <p><strong>Edit</strong>:</p>
  
  <p>Got this working.</p>
  
  <pre><code>SELECT word, (
      IF(LOCATE('o', word) &gt; 0, 1, 0) + 
      IF(LOCATE('r', word) &gt; 0, 1, 0) +
      IF(LOCATE('z', word) &gt; 0, 1, 0) +
      IF(LOCATE('a', word) &gt; 0, 1, 0) +
      IF(LOCATE('d', word) &gt; 0, 1, 0)) AS chars_present
  from words
  HAVING chars_present = 5
  </code></pre>
  
  <p>Now how would I query for words containing the letter <code>r</code> twice?</p>