I have an excel CSV file that I have imported into a database. There is a field called groups that includes all the groups a specific person belongs to. The groups are separated by a | (Pipe) character. I would like to run through this field for each person searching for the group to see if they belong but I am having a hard time figuring out how to create a loop to read through all of them.
Table example
------------------------------------
|Name | Groups |
------------------------------------
|Bob | Cleaning|Plumber |
|Sue | Admin|Secretary|Pay_role |
|Joe | Engineer |
|Frank | Plumber|Admin |
|James | Plumber|Carpenter |
I figured out how to grab the first group before the | but I don't know how to read each field after that
SELECT substring(Groups,1,((instr(Groups,'|')-1))) as ExtractString
from DB_groups
In the future I would like to add people to a group and delete people from a group so I am looking for a query that will allow me to see everyone's group like:
Sue | Admin
Sue | Secretary
Sue | Pay_r
ole
Maybe there is a better way to do this but the CSV file has 25k records so I am kinda stuck with what is already in there. Thanks for the help.