title: Remove not found word from mySQL query
body: <p>I am trying to make search and need to remove word from query, that do not have match. </p>
  
  <p>Lets say there is 3 words: <strong>one</strong>, <strong>two</strong> and <strong>three</strong>. If one is not found, then I need to rerun query with other two words (I get result Where <code>empty_space</code> AND <code>two</code> AND <code>three</code>, so query finds nothing). And so on. But I don't know how to identify unmatched word and run query again with other two words. </p>
  
  <p>EDIT: If I use this code, to count elements in array with <code>$i++</code>, query - <code>one two three</code>:</p>
  
  <pre><code>if(!empty($d)) {
       if($i &lt; 2) {
        $like_str .= " (title LIKE '%".$keyword."%')";
       } else {
        $like_str .= " AND (title LIKE '%".$keyword."%')";
       }
      }
  </code></pre>
  
  <p>Result: <code>SELECT * FROM shop_products_ WHERE AND (title LIKE '%two%') AND (title LIKE '%three%')</code></p>
  
  <p>And with words that exist, query - <code>one two</code></p>
  
  <pre><code>if(!empty($d)) {
       if($key &lt; 1) {
        $like_str .= " (title LIKE '%".$keyword."%')";
       } else {
        $like_str .= " AND (title LIKE '%".$keyword."%')";
       }
      }
  </code></pre>
  
  <p>Result: <code>SELECT * FROM shop_products_ WHERE (title LIKE '%one%') AND (title LIKE '%two%')</code></p>