title: MySQL join query to create a custom report
body: <p>Suppose, I have two table in MySQL Database. First one named <code>products</code> and second is <code>sales</code>.</p>
  
  <p>Let me keep three different entries for <code>products</code> table....</p>
  
  <pre><code>+-------+-----------------+-----------+--------+
  |id     | productname     | quantity  | uom    |
  +-------+-----------------+-----------+--------+
  |1      | water bottle    | 20        | piece  |
  |2      | cable           | 200       | meter  |
  |3      | soap            | 1         | piece  |
  +-------+-----------------+-----------+--------+
  </code></pre>
  
  <p>Also I am entering few sales in <code>sales</code> table-</p>
  
  <pre><code>+-------+---------------------+-----------+--------+-----------+
  |id     | date                | quantity  | uom    | productid |
  +-------+---------------------+-----------+--------+-----------+
  |1      | 2013-06-21 09:34:00 | 20        | meter  |     2     |
  |2      | 2013-06-21 10:35:00 | 100       | meter  |     2     |
  |3      | 2013-06-21 11:36:00 | 1         | piece  |     3     |
  +-------+---------------------+-----------+--------+-----------+
  </code></pre>
  
  <p>In above <code>sales</code> table <code>productid</code> is <code>foreign key</code>. Every sales entry keeping that <code>productid</code>. Now, How to create a report with single entry from left table and multiple entry from right table based on foreign key.</p>
  
  <p>Let me create a mockup of the report-</p>
  
  <pre><code>+-----------------+-----------+--------+---------------------+-----------+
  | productname     | quantity  | uom    | date                | quantity  |
  +-----------------+-----------+--------+---------------------+-----------+
  | cable           | 200       | meter  | 2013-06-21 09:34:00 | 20        |
  |                 |           |        | 2013-06-21 10:35:00 | 100       |
  | soap            | 1         | piece  | 2013-06-21 11:36:00 | 1         |
  | water bottle    | 20        | piece  |                     |           |
  +-----------------+-----------+--------+---------------------+-----------+
  </code></pre>
  
  <p>Is it possible to create above reports based on foreign key using MySQL?</p>