I have a record that looks like this in the database (As an example).
ID, Name, Brand
1, 'Bike', 'Schwinn'
2, 'Car', 'Ford, Honda, Chevy'
3, 'Bike', 'Schwinn, Trex'
4, 'Car', 'Honda'
I need to export the data out and create multiple records where Brand has multiple entries. I also need to increase the ID on output so I don't have duplicates. (I can use a sequence for this and would set it higher to my max value in db).
My output would look like
ID, Name, Brand
1, Bike, Schwinn
2, Car, Ford
Sequence.nextval, Car, Honda
Sequence.nextval, Car, Chevy
3, Bike, Schwinn
Sequence.nextval, Bike, Trex
4, Car, Honda
I would like to try and to this with a SQL
statement. Basically I'm dumping this data as a csv
file via straight SQL
.
My difficulty is trying to loop/split
through the Brand column.