I have inherited a database, and in my efforts to make it cleaner and more useful, I have encountered the following problem.
After moving the files column to a seperate table, I now have the task of seperating out these files into different rows. Please see my example below.
key | jobid | files |
--------------------------------------------
1 30012 file1.pdf;file2.pdf
2 30013 file3.pdf
3 30014 file4.pdf;file5.pdf;file6.pdf
I would like an SQL statement that would make the table into the following:
key | jobid | files |
--------------------------------------------
1 30012 file1.pdf
2 30013 file3.pdf
3 30014 file4.pdf
4 30012 file2.pdf
5 30014 file5.pdf
6 30014 file6.pdf
It doesnt matter if the original entrys must be deleted to achieve this, so the following solution would also be acceptable:
key | jobid | files |
--------------------------------------------
4 30012 file1.pdf
5 30013 file3.pdf
6 30014 file4.pdf
7 30012 file2.pdf
8 30014 file5.pdf
9 30014 file6.pdf
Basically I just need the files string split on the ; delimiter and a new row created with the split strings.
Any help you can provide would be appreciated.