title: mysql update a table with counts of another table
body: <p>if you could help I would be very thankful.
  there are two tables,  customers and lead_report</p>
  
  <p>I want to take the counts from the first column and place them in the matching row of the second column.</p>
  
  <p>select leadsource,count(*)  from customers where leadsource is not null and leadsource !="" group by leadsource;</p>
  
  <pre><code>select leadsource,count(*)  from customers where leadsource is not null  and leadsource !="" group by leadsource;
  
  +---------------------+----------+
  | leadsource          | count(*) |
  +---------------------+----------+
  | Show 2014           |        2 |
  | Show 2013           |        4 |
  | By Me               |        1 |
  +---------------------+----------+
  
  
  select source,leads from lead_report;
  
  +---------------------+-------+    
  | source              | leads |
  +---------------------+-------+
  | Show 2014           |     0 |
  | Show 2013           |     0 |
  | By Me               |     0 |
  +---------------------+-------+
  
  
  
  update lead_report leads inner join 
  (select leadsource,count(*)  from customers where leadsource is not null    and leadsource !="" group by leadsource)
  customers using (leadsource) set lead_report.leads =  customers.leadsource;
  ERROR 1054 (42S22): Unknown column 'leadsource' in 'from clause'
  </code></pre>