1

I have table:

| code   |  name  |
|--------|--------|
| A      |  name1 |
| A      |  name2;name3 |

I want to change data in table:

| code   |  name  |
|--------|--------|
| A      |  name1 |
| A      |  name2 |
| A      |  name3 |

How do it? Please help me!

2
  • 1
    Does the names column always have just one name or two separated by a semi colon? Have you tried something yet? Commented Sep 14, 2017 at 10:06
  • The name column maybe: 'name1' or 'name1;name3' or 'name1;name2;name3' Commented Sep 14, 2017 at 10:11

1 Answer 1

3

You can do:

select
    code,
    unnest(string_to_array("name", ';'))
from codename

Demo

Sign up to request clarification or add additional context in comments.

1 Comment

Wow! Thanks @tim-biegeleisen for the demo. It is really nice to see it working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.