title: SQLselect and pivot depending on two columns
body: <p>I have two tables table1 with col1 &amp; table2 with col2 and col3
  I'm trying the following code to select them:</p>
  
  <pre><code>select col1,col2,col3
  from table1
  inner join table2 on table1.id = table2.table1_id
  </code></pre>
  
  <p>it gives me the result as shown:
  <a href="https://i.stack.imgur.com/FKpPf.png" rel="nofollow noreferrer">selected result</a></p>
  
  <p>I want to get this result:</p>
  
  <p><a href="https://i.stack.imgur.com/ojeUL.png" rel="nofollow noreferrer">Final result</a></p>
  
  <p>how could I do this?
  thanks in advance...</p>