I have got a table with two columns: ID and cars. Sample data looks like:
ID | Cars
-----------------
1 | opel, honda and land rover
2 | ford and porshe, damaged
3 | volkswagen
4 | opel, seat, damaged
I would like to split it into:
ID | Cars
-----------------
1 | opel
1 | honda
1 | land rover
2 | ford
2 | porshe, damaged
3 | volkswagen
4 | opel
4 | seat, damaged
So the delimiter is and or , but not , damaged
How to use regex to split it in postgresql?
EDIT:
And how to make it working for records like
5 | land rover and opel, and ford
6 | ford; mazda and toyota