title: Searching multiple keywords against multiple columns/tables in a database. PHP + MYSQL
body: <p>I am in the process of producing a site search for my website (<a href="http://jpdesigns.me/studentnights" rel="nofollow noreferrer">http://jpdesigns.me/studentnights</a>) and have currently managed to implement searching across multiple tables using a keyword following the answers given in this question - 
  <a href="https://stackoverflow.com/questions/6574564/php-mysql-search-multiple-tables-using-a-keyword">PHP mysql search multiple tables using a keyword</a> <br /><br />
  I am currently searching over 3 tables.<br />
  - Clubs<br />
  - Events<br />
  - Music</p>
  
  <p>And i have the following query:<br /></p>
  
  <pre><code>$keystring = $mysqli-&gt;real_escape_string($_POST["s"]);
  $keystring = strtoupper($keystring);
  $key = "%".$keystring."%";
  
  $search_stmt = $mysqli-&gt;prepare("SELECT id, name, type AS 'col3', city AS 'col4', 'Club' AS 'table' 
                                   FROM studentnights_clubs 
                                   WHERE UCASE(name) LIKE ? OR UCASE(city) LIKE ?
                                   UNION
                                   SELECT id, name, description AS 'col3', image AS 'col4', 'Event' AS 'table' 
                                   FROM studentnights_events 
                                   WHERE UCASE(name) LIKE ?
                                   UNION
                                   SELECT id, name, '' AS 'col3', '' AS 'col4', 'Genre' AS 'table' 
                                   FROM studentnights_music 
                                   WHERE UCASE(name) LIKE ?
                                   ORDER BY
                                      CASE
                                          WHEN name LIKE ? THEN 1
                                          WHEN name LIKE ? THEN 3
                                          ELSE 2
                                      END
                                  LIMIT 10");
  $search_stmt-&gt;bind_param('ssssss', $key, $key, $key, $key, $key, $key);
  $search_stmt-&gt;execute();
  $search_stmt-&gt;store_result();
  $search_stmt_num = $search_stmt-&gt;num_rows;
  $search_stmt-&gt;bind_result($id, $name, $col3, $col4, $table);
  </code></pre>
  
  <p><br /></p>
  
  <p>Note: Blank columns entered in the music table are required to make the query work, union queries require the same number of columns being selected in each table.<br /><br /></p>
  
  <p>Onto the actual question. Whereas by above query search the multiple tables fine with the one keyword i want to expand on this so that multiple keywords can be taken into consideration.<br /></p>
  
  <p>This is easiest to explain by letting you see in real time.</p>
  
  <blockquote>
    <p>Go to <a href="http://jpdesigns.me/studentnights/" rel="nofollow noreferrer">http://jpdesigns.me/studentnights/</a><br />
    Enter 'mint' into the search bar, dont press enter, let ajax do its work.<br />
    Notice 2 Clubs Are Displayed, Mint Club (Leeds), Mint Club (London).<br />
    Add 'leeds' into the search bar (so 'mint leeds').<br />
    Notice both clubs disappear.<br /></p>
  </blockquote>
  
  <p>What i want is, when 'mint leeds' is typed into the search bar it shows mint club in leeds,<br />
  because the 'name' of club is 'mint club' (thus contains the word 'mint')<br />
  and its in the 'city' called 'leeds'<br /><br /></p>
  
  <p>Thank you for reading and know that any help would be massively appreiciated.</p>
  
  <p><br />EDIT: Stament updated so that is parameterised.</p>