title: SQL Search - one word less at a time - MySQL & PHP
body: <p>I have a phrase which I search for in my database, e.g. "Hawthorne Heights - Fragile Future"</p>
  
  <p>This produces 1 result, but, if I search for "Hawthorne Heights" only I get more results.</p>
  
  <p>My question is, is it possible to reduce the terms of a search until I receive the desired number of results or no more.</p>
  
  <p>E.g. initial search</p>
  
  <p>"Hawthorne Heights - Fragile Future"</p>
  
  <p>then</p>
  
  <p>"Hawthorne Heights - Fragile"</p>
  
  <p>then</p>
  
  <p>"Hawthorne Heights"</p>
  
  <p>then</p>
  
  <p>"Hawthorne"</p>
  
  <p>The initial search term could be one word in which case 1 pass is all thats needed, or, it could be ten words.</p>
  
  <p>Is this possible in one query or would I have to reduce the phrase then search again...if so how would I reduce the phrase?</p>
  
  <p>Many thanks for any help.</p>
  
  <p>Below is the code I use currently for the query:</p>
  
  <pre><code>$searchTerm = trim($searchTerm);
  
      $result345 = mysql_query("SELECT main_category, PRid, title, genre, imageURL, lowprice, highprice, prodcatID from PRprodINFO2 where (($title LIKE '%$searchTerm%') AND (imageURL &lt;&gt;'') $is_cat_id) $genre order by $order_col $asc_desc limit 2000",$db);
  </code></pre>
  
  <p>The $variables (e.g. $title, $is_cat_id etc) are dynamic but don't affect the query, its $searchTerm where the phrase is stored</p>