title: MYSQL Query to compare the results of two queries?
body: <p>I am currently working on a search feature for a website that searches through a database for a specific animal. </p>
  
  <p>Say the user inputs <code>rabbit</code>, the search will go through the <code>db</code> and display the results for <code>rabbit</code>. </p>
  
  <p>Now say a user inputs <code>bunny</code> the search will go through the <code>db</code> but will not find a match for <code>bunny</code>. </p>
  
  <p>Most people know that <code>bunny</code> means <code>rabbit</code>, but the database doesn't know that. At this point I have implemented a <code>MySQL</code> thesaurus within the same database to search for synonyms of what the user inputs. </p>
  
  <p>This means that if the user inputs <code>bunny</code> it will display a list of synonyms for bunny. </p>
  
  <p>In that list there is the word <code>Rabbit</code> and I am trying to pull that word out of there to generate a match. At this point I have the following.</p>
  
  <pre><code>"SELECT  `engname` FROM  `searchtestdb` WHERE  `engname` IS NOT NULL  ";
  </code></pre>
  
  <p>-- This displays the english name of every animal within that table. --</p>
  
  <pre><code>"SELECT synonyms.* FROM words LEFT JOIN synonyms ON synonyms.word_id = words.word_id WHERE word = \"$searchBox\""
  </code></pre>
  
  <p>-- This displays the synonyms for <code>$searchBox</code> which is the word the user inputs.  --</p>
  
  <p>Both of these queries display what I want them to display. In other words, the first query gives me all of the animals names in the table, and the second query gives me the synonyms for the word the user inputed.</p>
  
  <p>At this point my problem is how to compare the synonyms to all the animals names. I've tried several queries with the <code>LIKE</code> command but I keep getting syntax errors.</p>
  
  <p>Is what I am asking possible? If not what would be a better course of action? Any help would be greatly appreciated. </p>
  
  <p>Thank You.</p>
  
  <p>I got a semi fiddle going for y'all.</p>
  
  <p><a href="http://sqlfiddle.com/#!2/47d42/3" rel="nofollow">http://sqlfiddle.com/#!2/47d42/3</a></p>
  
  <p>It only works for "bunny" since the entire synonym and word list is too big for fiddle.</p>