title: Left Join Multiple Tables
body: <p>My mysql database structure looks as follows</p>
  
  <p><strong>Products Table</strong></p>
  
  <pre><code>+----+--------+-------------+-------+
  | id | itemid |    title    | price |
  +----+--------+-------------+-------+
  |  1 |      1 | Dell XPS 10 |  1000 |
  |  2 |      1 | Dell XPS 13 |  1100 |
  |  3 |      1 | HP 1        |  1100 |
  +----+--------+-------------+-------+
  </code></pre>
  
  <p><strong>Items Table</strong></p>
  
  <pre><code>+----+-------------+
  | id | description |
  +----+-------------+
  |  1 | Laptop      |
  |  2 | Monitors    |
  +----+-------------+
  </code></pre>
  
  <p><strong>Parameters Table</strong></p>
  
  <pre><code>+----+--------+------------------+
  | id | itemid |   description    |
  +----+--------+------------------+
  |  1 |      1 | Brand            |
  |  2 |      1 | Series           |
  |  3 |      1 | Color            |
  |  4 |      1 | Operating System |
  +----+--------+------------------+
  </code></pre>
  
  <p><strong>Specifications Table</strong></p>
  
  <pre><code>+----+-----------+-------------+-------------+
  | id | productid | parameterid | description |
  +----+-----------+-------------+-------------+
  |  1 |         1 |           1 | Dell        |
  |  2 |         1 |           2 | XPS         |
  |  3 |         1 |           3 | Red         |
  |  4 |         1 |           4 | Windows 10  |
  |  5 |         2 |           1 | Dell        |
  |  6 |         2 |           2 | XPS         |
  |  7 |         2 |           3 | Black       |
  |  8 |         2 |           4 | Windows 7   |
  |  9 |         3 |           1 | HP          |
  | 10 |         3 |           2 | 1           |
  | 11 |         3 |           3 | Black       |
  | 12 |         3 |           4 | Windows 10  |
  +----+-----------+-------------+-------------+
  </code></pre>
  
  <p>I am trying to out following result</p>
  
  <pre><code> +----+-----------+-------------+-------+-----------------+----------------------+--------------------------+
   | id | productid |    title    | price | itemdescription | parameterdescription | specificationdescription |
   +----+-----------+-------------+-------+-----------------+----------------------+--------------------------+
   |  1 |         1 | Dell XPS 10 |  1000 | Laptop          | Brand                | Dell                     |
   |  1 |         1 | Dell XPS 10 |  1000 | Laptop          | Series               | XPS                      |
   +----+-----------+-------------+-------+-----------------+----------------------+--------------------------+
  </code></pre>
  
  <p>Instead of this I am getting</p>
  
  <pre><code> +----+-----------+-------------+-------+-----------------+----------------------+--------------------------+
   | id | productid |    title    | price | itemdescription | parameterdescription | specificationdescription |
   +----+-----------+-------------+-------+-----------------+----------------------+--------------------------+
   |  1 |         1 | Dell XPS 10 |  1000 | Laptop          | Brand                | Dell                     |
   |  1 |         1 | Dell XPS 10 |  1000 | Laptop          | Brand                | XPS                      |
   |  1 |         1 | Dell XPS 10 |  1000 | Laptop          | Brand                | Red                      |
   |  1 |         1 | Dell XPS 10 |  1000 | Laptop          | Brand                | Windows 10                      |
   +----+-----------+-------------+-------+-----------------+----------------------+--------------------------+
  </code></pre>
  
  <p>I am using following mysql query</p>
  
  <pre><code>SELECT products.title, products.price, items.description, parameters.description, specifications.description
  FROM products
  LEFT JOIN items ON products.itemid = items.id
  LEFT JOIN parameters ON parameters.itemid = items.id
  LEFT JOIN specifications ON specifications.productid = products.id
  LIMIT 0 , 30
  </code></pre>
  
  <p>Secondly is it possible to have all the parameters &amp; specifications listed in same row?</p>
  
  <pre><code> +----+-----------+-------------+-------+-----------------+--------------------------+--------------------------+--------------------------+
   | id | productid |    title    | price | itemdescription | specificationdescription | specificationdescription | specificationdescription |
   +----+-----------+-------------+-------+-----------------+--------------------------+--------------------------+--------------------------+
   |  1 |         1 | Dell XPS 10 |  1000 | Laptop          | Dell                     | XPS                      | Red                      |
   +----+-----------+-------------+-------+-----------------+--------------------------+--------------------------+--------------------------+
  </code></pre>
  
  <p>If anyone has any suggestions on how to improve the database structure, I am open to ideas to optimize it. Thanks</p>
  
  <p>Following is the output to @Shakir answer</p>
  
  <pre><code>+-------------+-------+-------------+------------------+-------------+
  |    title    | price | description |   description    | description |
  +-------------+-------+-------------+------------------+-------------+
  | Dell XPS 10 |  1000 | Laptop      | Brand            | Dell        |
  | Dell XPS 10 |  1000 | Laptop      | Series           | Dell        |
  | Dell XPS 10 |  1000 | Laptop      | Color            | Dell        |
  | Dell XPS 10 |  1000 | Laptop      | Operating System | Dell        |
  | Dell XPS 10 |  1000 | Laptop      | Screen Size      | Dell        |
  | Dell XPS 10 |  1000 | Laptop      | Touchscreen      | Dell        |
  | Dell XPS 10 |  1000 | Laptop      | Brand            | XPS         |
  | Dell XPS 10 |  1000 | Laptop      | Series           | XPS         |
  | Dell XPS 10 |  1000 | Laptop      | Color            | XPS         |
  | Dell XPS 10 |  1000 | Laptop      | Operating System | XPS         |
  | Dell XPS 10 |  1000 | Laptop      | Screen Size      | XPS         |
  | Dell XPS 10 |  1000 | Laptop      | Touchscreen      | XPS         |
  | Dell XPS 10 |  1000 | Laptop      | Brand            | Black       |
  | Dell XPS 10 |  1000 | Laptop      | Series           | Black       |
  | Dell XPS 10 |  1000 | Laptop      | Color            | Black       |
  | Dell XPS 10 |  1000 | Laptop      | Operating System | Black       |
  | Dell XPS 10 |  1000 | Laptop      | Screen Size      | Black       |
  | Dell XPS 10 |  1000 | Laptop      | Touchscreen      | Black       |
  | Dell XPS 10 |  1000 | Laptop      | Brand            | Windows 10  |
  | Dell XPS 10 |  1000 | Laptop      | Series           | Windows 10  |
  | Dell XPS 10 |  1000 | Laptop      | Color            | Windows 10  |
  | Dell XPS 10 |  1000 | Laptop      | Operating System | Windows 10  |
  | Dell XPS 10 |  1000 | Laptop      | Screen Size      | Windows 10  |
  | Dell XPS 10 |  1000 | Laptop      | Touchscreen      | Windows 10  |
  +-------------+-------+-------------+------------------+-------------+
  </code></pre>