I have the following table, named stores:
store_id INT
emails VARCHAR
That contains values:
store_id | emails |
---|---|
1 | [email protected],[email protected] |
2 | [email protected],[email protected] |
4 | [email protected] |
And I want to generate the following set:
store_id | emails |
---|---|
1 | [email protected] |
1 | [email protected] |
2 | [email protected] |
2 | [email protected] |
4 | [email protected] |
As you can see I want to split the emails field into a separate record containing only one email address. Do you have any idea how I can do that?
So far I managed to create the following query:
select store_id,string_to_array(emails,',') from stores
But I don't know how I can split the string_to_array
to its own row.