I have a table (called toy table) which shows for each toy type the sales ID processed, with commas between different sales IDs. Please note that my data schema is not this way. But I aggregate data on the toy level, to generate a report.
|------------------------|------------------------|
| Toy | IDs |
|------------------------|------------------------|
| Buzz Lightyear | 22,33,44 |
| Woody | 24,41 |
|------------------------|------------------------|
I have another table (called status table) which has status for each order ID.
|------------------------|------------------------|
| ID | Status |
|------------------------|------------------------|
| 22 | running |
| 33 | paused |
| 44 | running |
| 24 | cancelled |
| 41 | finished |
|------------------------|------------------------|
I want to make a table (through a join) in which I can have a column for status separated by commas, in the right order of sales IDs, and also a column for running IDs only. It would look like this:
|------------------------|------------------------|------------------------|-----------------------|
| Toy | IDs | Status | Running IDs. |
|------------------------|------------------------|------------------------|-----------------------|
| Buzz Lightyear | 22,33,44 |running, paused, running| 22,44 |
| Woody | 24,41 | cancelled, finished | |
|------------------------|------------------------|------------------------|-----------------------|
I dont know how to make the join. I've tried finding the position of ID through find_in_set() but I just can't seem to progress after that. I have to report on the toy level so there cannot be more than one toy in a row in the final dataset.