title: Searching by name through multiple fields
body: <p>I have a table that, besides other information, contains names. I want to search for a name and get the field 'unique_id'.</p>
  
  <p>The fields that could contain the name (or part of it) are:</p>
  
  <pre><code>f_name1, l_name1, f_name2, l_name2, prop_name
  </code></pre>
  
  <p>Now let's say the database contains this entry:</p>
  
  <pre><code>unqiue_id = 1, 
  f_name1   = 'Barack',
  l_name1   = 'Obama', 
  f_name2   = 'Michelle', 
  l_name2   = 'Obama', 
  prop_name = 'White House',
  ...
  </code></pre>
  
  <p>and I have this string given in php:</p>
  
  <pre><code>$q = 'Barack Obama'; //or 'Michelle' or 'White House' or ...
  </code></pre>
  
  <p>What's the sql to get the 'unqiue_id' from that row?</p>
  
  <pre><code>SELECT unique_id FROM members WHERE (?)
  </code></pre>
  
  <p>One idea I had was to explode(' ', $q) and use LIKE '%...%' for everything and somehow count the number of conditions that are true and then ORDER BY that but I don't know if that's possible an if how to do it in SQL.</p>
  
  <p>Edit1:</p>
  
  <p>I came up with this solution thanks to 'PM 77-1's comment:</p>
  
  <pre><code>SELECT unique_id
  FROM members
  WHERE CONCAT( f_name1, l_name1, f_name2, l_name2, prop_name ) LIKE '%Barack%Obama%'
  </code></pre>
  
  <p>(replacing white-spaces with '%' in php)</p>
  
  <p>However this only works if the input string is in the correct order...</p>