title: MySQL query not returning the desired results
body: <p>I have the query below which queries the following two tables:</p>
  
  <h2>Users</h2>
  
  <pre><code>id | gender | interested_men | interested_wmen | name | dob      | email            | account | photoURL | timestamp
   8 | 1      |0               |1                |Jamie |1987-07-04|jampez77@gmail.com| 1       | https://.|2015-11-16 17:47:33
   9 | 0      |1               |1                |Jamima|1987-07-04|jampez87@gmail.com| 1       | https://.| 2015-11-17 14:51:38
  </code></pre>
  
  <h2>Locations</h2>
  
  <pre><code>id | uid | lat         | lng         | timestamp
  8  | 9   | 53.47213437 | -2.06999151 | 2015-11-17 15:05:37
  7  | 8   | 53.47213437 | -2.06999151 | 2015-11-16 17:47:33
  </code></pre>
  
  <p>Here is the query, I'd expect it to return the details for the user called Jamima but I don't get any results. I can't see anything wrong with the syntax so i'm not sure.</p>
  
  <pre><code>SELECT DISTINCT 
  l.uid , 
  u.account , 
  (
      3959 * acos
      ( 
          cos( 
              radians(53.47213437) 
          ) * 
          cos( 
              radians( lat) 
          ) * 
          cos( 
              radians( lng) - radians(-2.06999151) 
          ) + 
          sin( 
              radians(53.47213437) 
          ) * 
          sin( 
              radians( lat )
          ) 
      ) 
  ) distance, 
  TIMESTAMPDIFF(YEAR, dob, CURDATE()) AS age 
  FROM locations l 
  INNER JOIN users u ON l.uid = u.id 
  WHERE uid != 8 
  AND gender = 0 
  AND account = 1 
  HAVING distance &lt;= 200 
  AND age &gt;= 23 
  AND age &lt;= 33 
  ORDER BY RAND()
  </code></pre>
  
  <p>I've noticed that if I remove the gender and account parts of the where clause i get the correct results through. even if though they match the where clause </p>