1

My SQL query has "connect by regexp_substr". How do I convert it to PostgreSQL 10 query ?

I have tried this in Ubuntu and toad...

  select regexp_substr('1,2,4','[^,]+', 1, level) from dual
    connect by regexp_substr('1,2,4', '[^,]+', 1, level) is not null;

How to do I get convert above query to PostgreSQL version 10?

1
  • 2
    Please provide sample data, desired results, and an explanation of the logic you want to implement. Commented Jul 25, 2019 at 18:46

2 Answers 2

2

string_to_array() is typically faster if no regular expression is needed.

select *
from unnest(string_to_array('1,2,4', ',')) as t(c);
Sign up to request clarification or add additional context in comments.

Comments

1

If I understand correctly, you want to split a comma-delimited string into rows. For that, use regexp_split_to_table():

select regexp_split_to_table('1,2,4', ',')

In Postgres, it is possible that you would really phrase the overall query using arrays. If you have a question about a larger query, ask in a new question.

Comments

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.