title: In MySQL, how to select empty records
body: <p>I have the following MySQL Table Structure:</p>
  
  <pre><code>mysql&gt; desc customers;
  +---------------------+-------------+------+-----+---------+-------+
  | Field               | Type        | Null | Key | Default | Extra |
  +---------------------+-------------+------+-----+---------+-------+
  | hash                | varchar(32) | NO   | PRI | NULL    |       |
  | date_joined         | date        | NO   |     | NULL    |       |
  | agent_code          | int(5)      | NO   | UNI |         |       |
  +---------------------+-------------+------+-----+---------+-------+
  
  mysql&gt; desc persons;
  +--------------------+-------------+------+-----+---------+-------+
  | Field              | Type        | Null | Key | Default | Extra |
  +--------------------+-------------+------+-----+---------+-------+
  | agent_code         | int(5)      | NO   | UNI |         |       |
  | team_id            | int(2)      | YES  |     | 0       |       |
  | hash               | varchar(32) | NO   | PRI | NULL    |       |
  +--------------------+-------------+------+-----+---------+-------+
  
  mysql&gt; desc teams;
  +--------+-------------+------+-----+---------+----------------+
  | Field  | Type        | Null | Key | Default | Extra          |
  +--------+-------------+------+-----+---------+----------------+
  | id     | int(11)     | NO   | PRI | NULL    | auto_increment |
  | name   | varchar(20) | YES  |     | NULL    |                |
  | leader | varchar(32) | NO   | UNI | NULL    |                |
  +--------+-------------+------+-----+---------+----------------+
  </code></pre>
  
  <p>And I'd wish to generate a report of sales by Team.</p>
  
  <p>The SQL Query that I'm using is the following:</p>
  
  <pre><code>SELECT COUNT(`customers`.`agent_code) AS `customer_count`, `teams`.`name` 
  FROM  `customers` 
  JOIN  `persons` ON  `customers`.`agent_code` =  `persons`.`agent_code` 
  JOIN  `teams` ON  `persons`.`team_id` =  `teams`.`id` 
  GROUP BY  `teams`.`name`
  </code></pre>
  
  <p>And it shows the following information:</p>
  
  <pre><code>+----------------+--------+
  | customer_count | name   |
  +----------------+--------+
  |              3 | Team 1 |
  +----------------+--------+
  </code></pre>
  
  <p>However I'd like to see the "customer_count" of all the teams in the database, even if the customer_count is null (or zero) for a given team. I have 15 teams in my database, so I'd like to see something like:</p>
  
  <pre><code>+----------------+--------+
  | customer_count | name   |
  +----------------+--------+
  |              3 | Team 1 |
  |              0 | Team 2 |
  |              0 | Team 3 |
  |              0 | Team 4 |
  +----------------+--------+
  </code></pre>
  
  <p>I have tried to execute some variants of the following Query, but I always get an error saying that the syntax of OUTER JOIN is incorrect, even though I've read the documentation, and it is correct.</p>
  
  <pre><code> SELECT COUNT(  `customers`.`agent_code` ) AS  `customer_count` ,  `teams`.`name` 
   FROM  `customers` 
   LEFT JOIN  `persons` ON  `customers`.`agent_code` =  `persons`.`agent_code` 
   LEFT OUTER JOIN  `teams` ON  `persons`.`team_id` =  `teams`.`id` 
   GROUP BY  `teams`.`name` 
  </code></pre>
  
  <p>How can I alter my current query in order to display such result?</p>