title: Php/ MySql 'Advanced Search' Page
body: <p>I'm working on an 'advanced search' page on a site where you would enter a keyword such as 'I like apples' and it can search the database using the following options:</p>
  
  <blockquote>
    <p>Find : With all the words, With the
    exact phrase , With at least one of
    the words, Without the words</p>
  </blockquote>
  
  <p>I can take care of the 'Exact phrase' by:</p>
  
  <pre><code>SELECT * FROM myTable WHERE field='$keyword';
  </code></pre>
  
  <p>'At least one of the words' by:</p>
  
  <pre><code>SELECT * FROM myTable WHERE field LIKE '%$keyword%';//Let me know if this is the wrong approach
  </code></pre>
  
  <p>But its the 'With at least one of the words' and 'Without the words' that I'm stuck on. </p>
  
  <p>Any suggestions on how to implement these two?</p>
  
  <p><strong>Edit:</strong> Regarding 'At least one word' it wouldn't be a good approach to use explode() to break the keywords into words, and run a loop to add </p>
  
  <pre><code>(field='$keywords') OR ($field='$keywords) (OR)....
  </code></pre>
  
  <p>Because there are some other AND/OR clauses in the query also and I'm not aware of the maximum number of clauses there can be.</p>