title: join pivot table in mysql
body: <p>How to join different tables with pivote table</p>
  
  <p>I have 4 tables like </p>
  
  <pre><code> users
  
   id  |  name |
   -------------
    1  |  abc  |
    2  |  ccc  |
  
  user_profile
  
  id   |  user_id | email |
  -------------------------------
  1    |    1     | abc@gmail.com 
  2    |    2     | ccc@gmail.com
  
  skills
  
  id    |  skill_name  |
  --------------------------
  1    |   java       |
  2    |   php        | 
  
  user_skills
  
  user_id   | skill_id   |
  ---------------------------
   1       |   1        |
   1       |   2        |
   2       |   1        |  
  </code></pre>
  
  <p>The result should be</p>
  
  <pre><code> name  |  email       |  skills   |
   ----------------------------------
   abc   |abc@gmail.com | java, php |
   ccc   |ccc@gmail.com | java      |  
  </code></pre>
  
  <p>I am able to join multiple tables but I have problem joining pivote </p>
  
  <p>I have tried below with query </p>
  
  <pre><code> SELECT users.name,user_profiles.email, group_concat(programs.name) 
   from users
   JOIN user_profiles on user_profiles.user_id = users.id
   LEFT JOIN user_skills on user_skills.user_id = users.id
   LEFT JOIN skills on user_skills.skill_id = skills.id
   GROUP BY users.id
  </code></pre>
  
  <p>Can anyone help me on this please??Thanks</p>