title: Search a table based on multiple rows in another table
body: <p>Basically I have three MySQL tables:</p>
  
  <p><strong>Users</strong> - contains base information on users<br>
  <strong>Fields</strong> - describes additional fields for said users (e.g. location, dob etc.)<br>
  <strong>Data</strong> - Contains user data described via links to the fields table</p>
  
  <p>With the basic design as follows (the below is a stripped down version)</p>
  
  <p><strong>Users:</strong></p>
  
  <pre><code> ID | username | password | email | registered_date
  </code></pre>
  
  <p><strong>Fields</strong></p>
  
  <pre><code> ID | name | type
  </code></pre>
  
  <p><strong>Data:</strong></p>
  
  <pre><code> ID | User_ID | Field_ID | value
  </code></pre>
  
  <p>what I want to do is search Users by the values for the fields they have, e.g. example fields might be:</p>
  
  <p>Full Name<br>
  Town/City<br>
  Postcode<br>
  etc.</p>
  
  <p>I've got the following, which works when you're only wanting to search by one field:</p>
  
  <pre><code>SELECT `users`.`ID`,
         `users`.`username`,
         `users`.`email`,
         `data`.`value`,
         `fields`.`name`
  
  FROM `users`,
       `fields`,
       `data`
  
  WHERE `data`.`Field_ID` = '2'
  AND `data`.`value` LIKE 'london'
  AND `users`.`ID` = `data`.`User_ID`
  AND `data`.`Field_ID` = `fields`.`ID`
  
  GROUP BY `users`.`ID`
  </code></pre>
  
  <p>But what about if you want to search for Multiple fields? e.g. say I want to search for Full Name "Joe Bloggs" With Town/City set to "London"? This is the real sticking point for me.</p>
  
  <p>Is something like this possible with MySQL?</p>