I am newish to SQL to please excuse any ignorance. I have a table, called \'temp\' that contains one Field with one long comma seperated string, thus:
Field1
Ap
Oracle SQL:
SELECT REPLACE(SUBSTR(r_str, 1, INSTR(r_str, ',', 1, 1) - 1), ' ') AS r_substr_1
, REPLACE(SUBSTR(r_str, INSTR(r_str, ',', 1, 1) + 1, INSTR(r_str, ',', 1, 2) - INSTR(r_str, ',', 1, 1) - 1), ' ') AS r_substr_2
, REPLACE(SUBSTR(r_str, INSTR(r_str, ',', 1, 2) + 1, INSTR(r_str, ',', 1, 3) - INSTR(r_str, ',', 1, 2) - 1), ' ') AS r_substr_3
, REPLACE(SUBSTR(r_str, INSTR(r_str, ',', 1, 3) + 1, INSTR(r_str, ',', 1, 4) - INSTR(r_str, ',', 1, 3) - 1), ' ') AS r_substr_4
, REPLACE(SUBSTR(r_str, INSTR(r_str, ',', 1, 4) + 1), ' ') AS r_substr_5
FROM
(
SELECT 'Apples, oranges, pears,berries, melons' r_str FROM DUAL
);
Result: Apples oranges pears berries melons