Assuming the following:
Table "info":
id | target_ids
----|------------
1 | 2
2 |
3 | 4,1
4 | 2,3,1
Table "targets":
id | value
----|------------
1 | dog
2 | cat
3 | tiger
4 | lion
Using left join, I'm expecting something like this:
id | target_ids | value
----|---------------------
1 | 2 | cat
2 | |
3 | 4,1 | lion,dog
4 | 2,3,1 | cat,tiger,dog
I've tried this:
select info.*, targets.value from info left join targets on info.target_ids = targets.id
The results I got is single values in "value" column
id | target_ids | value
----|---------------------
1 | 2 | cat
2 | |
3 | 4,1 | lion
4 | 2,3,1 | cat
How can I get results as it's showing in the 3rd table? Thanks