In one of my database table, I have a a column containing values separated by commas like '127,765,715,716'.
Colums are : id, firstname, skills (with commas values).
I need to write a query and to retrieve all the skills. For the moment I do :
- a simple select
- a foreach for looping through all rows.
- Inside that foreach, if "skills" isn't empty, I explode the "skills column" containing commas into an array.
- I again do a loop in the new skills array
- I make a new SELECT the to get the id, name, color of the skill (from a new table)
This is really cpu costy, once I get 200 rows, the cpu is at 100% and it takes 20 seconds.
Is there a way to do it better ?