title: Querying MySQL for anagrams
body: <p>I have this script:</p>
  
  <pre><code>$db = mysql_connect($hostname, $db_user, $db_password);
  mysql_select_db($database,$db) or die( "Unable to select database");
  mysql_query("set names 'utf8'");
  
  $wordy = "pate";
  
  $query = mysql_query("SELECT DISTINCT * FROM $db_table WHERE word LIKE '[pate]' ORDER BY word DESC");
  $num = mysql_numrows($query); $i=0; 
  
  while ($i &lt; $num) {
      $word = mysql_result($query,$i,"word");
  
      echo $word." ";
      $i++;
  }
  </code></pre>
  
  <p><code>$db_table</code> contains English words. I want to echo out all possible anagrams; in this case it should echo <code>tape pate peat</code>. What query could I use to do this?</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/ms179859.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms179859.aspx</a> &lt;- here is a description</p>