title: MySQL Query - SUM of COUNT from multiple tables
body: <p>I have three tables:</p>
  
  <ul>
  <li><strong>customers</strong>: <em>id, name</em></li>
  <li><strong>contracts_jewels</strong>: <em>id, customer_id, paid, transferred, final_date</em></li>
  <li><strong>contracts_objects</strong>: <em>id, customer_id, paid, transferred, final_date</em></li>
  </ul>
  
  <p>As you see, the structure of the last two tables is the same.
  The "<em>paid</em>" and the "<em>transferred</em>" fields contain the value 0 or 1.</p>
  
  <p>What I need is to make a query which should return all the clients (no matter if they have contracts or not), and for each client:
  <em>id, name, <strong>count_contracts_all</strong>, <strong>count_contracts_active</em></strong></p>
  
  <p>where:</p>
  
  <ul>
  <li><strong>count_contracts_all</strong> would mean the sum of [SELECT COUNT( * ) FROM
  contracts_jewels WHERE customer_id=3 (for example)] and [SELECT
  COUNT( * ) FROM contracts_objects WHERE customer_id=3 (for example)]</li>
  <li><strong>count_contracts_active</strong> would mean the sum of [SELECT COUNT( * ) FROM
  contracts_jewels WHERE customer_id=3 AND final_date>=Now() AND paid=0
  AND transferred=0] and [SELECT COUNT( * ) FROM contracts_objects WHERE
  customer_id=3 AND final_date>=Now() AND paid=0 AND transferred=0]</li>
  </ul>
  
  <p>Any idea? Would you please help me? Thank you!</p>