title: mysql join, replace for comma separated strings
body: <p>Database: </p>
  
  <pre><code>table1 schema: name=q_values;  columns= id, name;
  table2 schema: name=signup_protect;  columns= first_name, last_name, uid;
  table3 schema: name=user_result;  columns= uid, value_ids;
  
  table1 data: [1, forest], [2, mountains]
  table2 data: [test, test, 123]
  table 3 data: [123, {1:2}]
  </code></pre>
  
  <p>I will need the query that gives me this result:</p>
  
  <pre><code>test, test, {forest, mountains}
  </code></pre>
  
  <p>which means that I join signup with result on uid, and I replace the <code>value_ids</code> with <code>q_value</code> names.</p>
  
  <p>This is what I did so far, but I only get the first name of the comaseparated value.</p>
  
  <pre><code>SELECT `signup_protect`.`first_name`, `signup_protect`.`last_name`, 
   (select name from q_values where id in (replace(`user_results`.`value_ids`,':', ','))) 
   FROM (`signup_protect`) JOIN `user_results` ON `user_results`.`uid` = `signup_protect`.`uid`
  </code></pre>
  
  <p>I use </p>
  
  <pre><code>(select name from q_values where id in (replace(`user_results`.`value_ids`,':', ','))) 
  </code></pre>
  
  <p>to replace the colons on my string with comma so I can treat them as array .</p>