title: SQL - get column names when value is 1
body: <p>I have a junction table: </p>
  
  <pre><code>id | warehouse | comp1 | comp2 | comp3 | comp4
  ----------------------------------------------
  1  | w1        |   1   |  0    |  1    |  1    =&gt; String: 'col1,col3,col4'
  2  | w2        |   1   |  1    |  0    |  1    =&gt; String: 'col1,col2,col4'
  3  | w3        |   0   |  1    |  0    |  0    =&gt; String: 'col2'
  </code></pre>
  
  <ul>
  <li>How to get the string of column names, if the value of column is 1? </li>
  </ul>
  
  <p><strong>Possible solution - change the junction table</strong> </p>
  
  <p>ommit working with column names, just work with substrings or masks 
  (using <code>like %comp1%</code> for example):</p>
  
  <pre><code>id | warehouse| companies
  -----------------------------------
  1  | w1       | 'comp1,comp3,comp4'
  2  | w2       | 'comp3'
  3  | w3       | 'comp1,comp2,comp4'
  </code></pre>