title: MYSQL count related records one query
body: <p>So i have a mysql query that queries a table "contacts" each contact then has purchases. Purchases are in a related table. I want to display each contacts name with the number of purchases they have made to the right like this:</p>
  
  <pre><code>Adam(1)
  Mike(8)
  Steve(3) 
  </code></pre>
  
  <p>My current sql looks like this:</p>
  
  <pre><code>SELECT * FROM contacts ORDER BY contacts.name ASC"
  </code></pre>
  
  <p>and my current table looks like this:</p>
  
  <pre><code>Adam
  Mike
  Steve
  </code></pre>
  
  <p>In order to pull the count of the related (purchases) table into the current table i know i have to join the "purchases" table some how and then use the GROUP BY and count() function but i am not sure how to construct this sql statement.  Can someone help me.  </p>
  
  <p>Again all i am trying to do is list a table (contacts) and count it's related records (purchases) and have it look like this:</p>
  
  <pre><code>Adam(1)
  Mike(8)
  Steve(3)
  </code></pre>
  
  <p>Thank you so much for any help.</p>