Database:
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}]
I will need the query that gives me this result:
test, test, {forest, mountains}
which means that I join signup with result on uid, and I replace the value_ids with q_value names.
This is what I did so far, but I only get the first name of the comaseparated value.
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`
I use
(select name from q_values where id in (replace(`user_results`.`value_ids`,':', ',')))
to replace the colons on my string with comma so I can treat them as array .
"{1:2}"(5 characters)?INexpects a comma separated list, but you're giving it a string. Have a look at this question of mine: stackoverflow.com/q/4155873/206403 and please consider not storing a (comma) separated list in a database, you should have one row for each value (do it, you'll thank me later on).