title: How to count by joining two tables
body: <p>I have 2 tables like this.</p>
  
  <p><strong>Table : Family Members</strong></p>
  
  <pre><code>----------------------------------
  |Address                 | Name  |
  ----------------------------------
  |North Jakarta City      | Andra |
  |North Jakarta City      | Halim |
  |South Jakarta City      | Irma  |
  |Thousand Island Village | Dian  |
  ----------------------------------
  </code></pre>
  
  <p><strong>Table : Member Details</strong></p>
  
  <pre><code>---------------
  | Name  | Age |
  ---------------
  | Andra | 1   |
  | Halim | 50  |
  | Irma  | 20  |
  | Dian  | 4   |
  ---------------
  </code></pre>
  
  
  
  <p>What is the correct query if I want to count members between the ages 0 and 4 who live in a 'city'? I've tried using this query but the result is incorrect. The correct result should be 1 since only Andra who lives in a city and between the ages 0 and 4. Please help me.</p>
  
  <pre><code>SELECT COUNT(family_members.name) AS total FROM family_members, member_details 
  WHERE family_members.address LIKE '%City%' AND member_details.age BETWEEN 0 AND 4
  </code></pre>